home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_plotutils.idb / usr / freeware / include / plotter.h.z / plotter.h
C/C++ Source or Header  |  2002-01-08  |  120KB  |  2,521 lines

  1. /* This is "plotter.h", the public header file for the C++ Plotter class
  2.    provided by GNU libplotter, a shared class library for 2-dimensional
  3.    vector graphics.  
  4.  
  5.    This file should be included by any code that uses the Plotter class.
  6.    If the Plotter class was installed without X Window System support, be
  7.    sure to do "#define X_DISPLAY_MISSING" before including this file.
  8.  
  9.    From the base Plotter class, the BitmapPlotter, MetaPlotter, TekPlotter,
  10.    ReGISPlotter, HPGLPlotter, FigPlotter, CGMPlotter, PSPlotter, AIPlotter,
  11.    SVGPlotter, GIFPlotter, PNMPlotter, PNGPlotter, and XDrawablePlotter
  12.    classes are derived.  The PNMPlotter and PNGPlotter classes are derived
  13.    from the BitmapPlotter class, the PCLPlotter class is derived from the
  14.    HPGLPlotter class, and the XPlotter class is derived from the
  15.    XDrawablePlotter class. */
  16.  
  17. /* If NOT_LIBPLOTTER is defined, this file magically becomes an internal
  18.    header file used in GNU libplot, the C version of libplotter.  libplot
  19.    has its own public header file, called "plot.h". */
  20.  
  21. /* Implementation note: In libplot, a Plotter is a typedef'd structure
  22.    rather than a class instance.  Because of the need to support both
  23.    libplot and libplotter, i.e. C and C++, all data members of derived
  24.    Plotter classes are declared in this file twice: once in the Plotter
  25.    structure (for C), and once in each derived class declaration (for C++). */
  26.  
  27. #ifndef _PLOTTER_H_
  28. #define _PLOTTER_H_ 1
  29.  
  30. /***********************************************************************/
  31.  
  32. /* Version of GNU libplot/libplotter which this header file accompanies.
  33.    This information is included beginning with version 4.0.
  34.  
  35.    The PL_LIBPLOT_VER_STRING macro is compiled into the library, as
  36.    `pl_libplot_ver'.  The PL_LIBPLOT_VER macro is not compiled into it.
  37.    Both are available to applications that include this header file. */
  38.  
  39. #define PL_LIBPLOT_VER_STRING "4.1"
  40. #define PL_LIBPLOT_VER         401
  41.  
  42. extern const char pl_libplot_ver[8];   /* need room for 99.99aa */
  43.  
  44. /***********************************************************************/
  45.  
  46. /* Support ancient C compilers, best not explained further. */
  47. #ifndef void
  48. #define voidptr_t void *
  49. #endif
  50.  
  51. /* If we're supporting X, include X-related header files needed by the
  52.    class definition. */
  53. #ifndef X_DISPLAY_MISSING
  54. #include <X11/Xlib.h>
  55. #include <X11/Intrinsic.h>
  56. #endif /* not X_DISPLAY_MISSING */
  57.  
  58. /* Include iostream, stdio support if this is libplotter rather than
  59.    libplot. */
  60. #ifndef NOT_LIBPLOTTER
  61. #include <iostream.h>
  62. #include <stdio.h>
  63. #endif
  64.  
  65. /* THE GLOBAL VARIABLES IN GNU LIBPLOTTER */
  66. /* There are two; both are user-settable error handlers. */
  67. #ifndef NOT_LIBPLOTTER
  68. extern int (*libplotter_warning_handler) (const char *msg);
  69. extern int (*libplotter_error_handler) (const char *msg);
  70. #endif
  71.  
  72.  
  73. /***********************************************************************/
  74.  
  75. /* Structures for points. */
  76.  
  77. typedef struct
  78. {
  79.   double x, y;
  80. } plPoint;
  81.  
  82. typedef struct
  83. {
  84.   int x, y;
  85. } plIntPoint;
  86.  
  87. /* Structures for paths, as painted by any Plotter. */
  88.  
  89. /* Normally, a simple path is a sequence of contiguous line segments,
  90.    circular arc segments, elliptic arc segments, quadratic Bezier segments,
  91.    or cubic Bezier segments.  All Plotters support line segments, but many
  92.    Plotters don't support the other types of segment.  Some Plotters also
  93.    support (closed) simple paths that are single circles, ellipses, or
  94.    "boxes" (rectangles aligned with the coordinate axes).
  95.  
  96.    A simple path that is a sequence of segments is represented internally
  97.    as a list of plPathSegments.  Each contains a single endpoint (x,y), and
  98.    specifies how to get there (e.g., via a pen-up motion, which is used for
  99.    the first point in a path, or via a line segment, or a curve defined by
  100.    control points).
  101.    
  102.    A well-formed simple path of this `segment list' type has the form:
  103.    { moveto { line | arc | ellarc | quad | cubic }* { closepath }? } */
  104.  
  105. /* Allowed values for the path segment type field. */
  106. typedef enum 
  107.   S_MOVETO, S_LINE, S_ARC, S_ELLARC, S_QUAD, S_CUBIC, S_CLOSEPATH
  108. } plPathSegmentType;
  109.  
  110. /* Structure for a path segment. */
  111. typedef struct
  112. {
  113.   plPathSegmentType type;
  114.   plPoint p;            /* endpoint of segment */
  115.   plPoint pc;            /* intermediate control point (if any) */
  116.   plPoint pd;            /* additional control point (S_CUBIC only) */
  117. } plPathSegment;
  118.  
  119. /* Allowed values for the path type field in a plPath (see below). */
  120. typedef enum 
  121.   PATH_SEGMENT_LIST,        /* the default kind */
  122.   PATH_CIRCLE, PATH_ELLIPSE, PATH_BOX /* supported by some Plotters */
  123. } plPathType;
  124.  
  125. /* Structure for a simple path.  The default kind of simple path is a list
  126.    of segments.  However, a simple path may also be a circle, ellipse, or
  127.    box, which some Plotter support as primitive drawing elements, at least
  128.    under some circumstances.  Other Plotters automatically flatten these
  129.    built-in primitives into segment lists.  The advisory `primitive' flag
  130.    is set to `true' to indicate that a segment list is in fact such a
  131.    flattened object. */
  132.  
  133. typedef struct
  134. {
  135.   plPathType type;    /* PATH_{SEGMENT_LIST,CIRCLE,ELLIPSE,BOX} */
  136.   double llx, lly, urx, ury;    /* bounding box */
  137.   /* simple path of segment list type */
  138.   plPathSegment *segments;    /* list of path segments */
  139.   int num_segments;        /* number of segments in list */
  140.   int segments_len;        /* length of buffer for list storage (bytes) */
  141.   bool primitive;        /* advisory (see above; some Plotters use it)*/
  142.   /* simple path of built-in primitive type (circle/ellipse/box) */
  143.   plPoint pc;            /* CIRCLE/ELLIPSE: center */
  144.   double radius;        /* CIRCLE: radius */
  145.   double rx, ry;        /* ELLIPSE: semi-axes */
  146.   double angle;            /* ELLIPSE: angle of first axis */
  147.   plPoint p0, p1;        /* BOX: opposite vertices */
  148.   bool clockwise;        /* CIRCLE/ELLIPSE/BOX: clockwise? */
  149. } plPath;
  150.  
  151. /* An integer counterpart to plPathSegment, used by some Plotters during
  152.    the mapping of segment-list paths to the device frame.  This shouldn't
  153.    be defined here, since it's so Plotter-specific. */
  154. typedef struct
  155. {
  156.   plPathSegmentType type;
  157.   plIntPoint p;            /* endpoint of segment */
  158.   plIntPoint pc;        /* intermediate control point (if any) */
  159.   plIntPoint pd;        /* additional control point (S_CUBIC only) */
  160.   double angle;            /* subtended angle (for S_ARC, if used) */
  161. } plIntPathSegment;
  162.  
  163. /* Values for the parameters `allowed_{arc|ellarc|quad|cubic}_scaling' of
  164.    any Plotter.  Those parameters specify which sorts of user frame ->
  165.    device frame affine transformation are allowed, if an arc or Bezier that
  166.    is part of a path is to be placed in the path buffer's segment list as a
  167.    single segment, rather than approximated as a polyline.
  168.  
  169.    These are also the possible values for the parameters
  170.    allowed_{circle|ellipse|box}_scaling' of any Plotter, which specify
  171.    whether any circle/ellipse/box should be placed in the path buffer as a
  172.    primitive, rather than split into arc segments or line segments and
  173.    placed in the segment list.
  174.  
  175.    The reason for extensively parametrizing the internal operation of any
  176.    Plotter (i.e. restricting what gets placed in its path buffer) is that
  177.    for many Plotters, the Plotter-specific operation _paint_path(), which
  178.    is called by endpath(), can't handle arbitrary drawing primitives,
  179.    because the Plotter's output format doesn't support them.
  180.  
  181.    The values AS_UNIFORM and AS_AXES_PRESERVED aren't used for Beziers, but
  182.    they're used for the other primitives.  Also, insofar as ellipses go, a
  183.    value of AS_AXES_PRESERVED for the allowed scaling is intepreted as
  184.    meaning that not only should the affine map preserve coordinate axes,
  185.    but the ellipse itself, to be placed in the path buffer, should have its
  186.    major and minor axes aligned with the coordinate axes.  See g_ellipse.c.  */
  187.  
  188. typedef enum 
  189.   AS_NONE,            /* primitive not supported at all */
  190.   AS_UNIFORM,            /* supported only if transf. is uniform  */
  191.   AS_AXES_PRESERVED,        /* supported only if transf. preserves axes */
  192.   AS_ANY            /* supported irrespective of transformation */
  193. } plScalingType;
  194.  
  195.  
  196. /**********************************************************************/
  197.  
  198. /* Structures for colors (we don't fully distinguish between 24-bit color
  199.    and 48-bit color, though we should). */
  200.  
  201. /* RGB */
  202. typedef struct
  203. {
  204.   int red;
  205.   int green;
  206.   int blue;
  207. } plColor;
  208.  
  209. /* BitmapPlotters (including PNMPlotters and PNGPlotters, which are
  210.    derived) and GIFPlotters use the libxmi scan-conversion library, which
  211.    is compiled into libplot/libplotter.  libxmi writes into a pixmap that
  212.    is made up of the following type of pixel.  We use a struct containing a
  213.    union, so that the compiled-in libxmi can be used both by GIF Plotters
  214.    (in which pixel values are color indices) and by BitmapPlotters (in
  215.    which pixel values are 24-bit RGB values).  We distinguish them by the
  216.    `type' field. */
  217. #define MI_PIXEL_TYPE struct \
  218. { \
  219.   unsigned char type; \
  220.   union \
  221.     { \
  222.       unsigned char index; \
  223.       unsigned char rgb[3]; \
  224.     } u; \
  225. }
  226.  
  227. /* values for the `type' field */
  228. #define MI_PIXEL_INDEX_TYPE 0
  229. #define MI_PIXEL_RGB_TYPE 1
  230.  
  231. #define MI_SAME_PIXEL(pixel1,pixel2) \
  232.   (((pixel1).type == MI_PIXEL_INDEX_TYPE \
  233.     && (pixel2).type == MI_PIXEL_INDEX_TYPE \
  234.     && (pixel1).u.index == (pixel2).u.index) \
  235.    || \
  236.   ((pixel1).type == MI_PIXEL_RGB_TYPE \
  237.     && (pixel2).type == MI_PIXEL_RGB_TYPE \
  238.     && (pixel1).u.rgb[0] == (pixel2).u.rgb[0] \
  239.     && (pixel1).u.rgb[1] == (pixel2).u.rgb[1] \
  240.     && (pixel1).u.rgb[2] == (pixel2).u.rgb[2]))
  241.  
  242.  
  243. /**********************************************************************/
  244.  
  245. /* Structure used for characterizing a page type (e.g. "letter", "a4"; see
  246.    our database of known page types in g_pagetype.h).  Any Plotter includes
  247.    a pointer to one of these.
  248.  
  249.    For all `physical' Plotters, i.e. those with a page type determined by
  250.    the PAGESIZE parameter, we map the window that the user specifies by
  251.    invoking space(), to a viewport whose default size is fixed and
  252.    Plotter-independent.  E.g., for any Plotter for which PAGESIZE is
  253.    "letter", the default viewport is a square of size 8.0in x 8.0in.
  254.  
  255.    All physical Plotters position this default viewport at the center of
  256.    the page, except that HPGLPlotters don't know exactly where the origin
  257.    of the device coordinate system is.  PCLPlotters do, though, when
  258.    they're emitting HP-GL/2 code (there's a field in the struct that
  259.    specifies that, see below).  See comments in g_pagetype.h. */
  260.  
  261. typedef struct
  262. {
  263.   const char *name;        /* official name, e.g. "a" */
  264.   const char *alt_name;        /* alternative name if any, e.g. "letter" */
  265.   const char *fig_name;        /* name used in Fig format (case-sensitive) */
  266.   bool metric;            /* metric vs. Imperial, advisory only */
  267.   double xsize, ysize;        /* width, height in inches */
  268.   double default_viewport_size;    /* size of default square viewport, in inches*/
  269.   double pcl_hpgl2_xorigin;    /* origin for HP-GL/2-in-PCL5 plotting */
  270.   double pcl_hpgl2_yorigin;  
  271.   double hpgl2_plot_length;    /* plot length (for HP-GL/2 roll plotters) */
  272. } plPageData;
  273.  
  274. /* Structure in which the user->NDC and user->device affine coordinate
  275.    transformations are stored.  Any drawing state includes one of these
  276.    structures.  The user->NDC transformation is a bit more fundamental,
  277.    since it's used as an attribute of all objects that get drawn.
  278.  
  279.    The user->device transformation is the product of the user->NDC
  280.    transformation and the NDC->device transformation (stored in the Plotter
  281.    itself, since it never changes after being initialized at Plotter
  282.    creation time).  The reason we precompute the user->device
  283.    transformation and store it here is that we use it so frequently. */
  284.  
  285. typedef struct
  286.   /* the user->NDC transformation */
  287.   double m_user_to_ndc[6];    /* 1. a linear transformation (4 elements) */
  288.                   /* 2. a translation (2 elements) */
  289.   /* the user->device transformation, precomputed for convenience */
  290.   double m[6];
  291.   /* data on user->device map, also precomputed for convenience */
  292.   bool uniform;            /* transf. scaling is uniform? */
  293.   bool axes_preserved;        /* transf. preserves axis directions? */
  294.   bool nonreflection;        /* transf. doesn't involve a reflection? */
  295. } plTransform;
  296.  
  297.  
  298. /**********************************************************************/
  299.  
  300. /* Drawing state structure.  Includes drawing attributes, and the state of
  301.    any uncompleted path object.  When open, i.e., when drawing a page of
  302.    graphics, any Plotter maintains a stack of these things.  Many of the
  303.    data members are device-dependent, i.e., specific to individual derived
  304.    Plotter classes, but it's more efficient to keep them here, in a single
  305.    structure.  The device-independent data members are listed first. */
  306.  
  307. typedef struct plDrawStateStruct
  308. {
  309. /***************** DEVICE-INDEPENDENT PART ***************************/
  310.  
  311. /* graphics cursor position */
  312.   plPoint pos;            /* graphics cursor position in user space */
  313.  
  314. /* affine transformation from user coordinates to normalized device
  315.    coordinates, and also to actual device coordinates (precomputed) */
  316.   plTransform transform;    /* see definition of structure above */
  317.  
  318. /* the compound path being drawn, if any */
  319.   plPath *path;            /* simple path being drawn */
  320.   plPath **paths;        /* previously drawn simple paths */
  321.   int num_paths;        /* number of previously drawn simple paths */
  322.   plPoint start_point;        /* starting point (used by closepath()) */
  323.  
  324. /* modal drawing attributes */
  325.   /* 1. path-related attributes */
  326.   const char *fill_rule;    /* fill rule */
  327.   int fill_rule_type;        /* one of FILL_*, determined by fill rule */
  328.   const char *line_mode;    /* line mode */
  329.   int line_type;        /* one of L_*, determined by line mode */
  330.   bool points_are_connected;    /* if not set, path displayed as points */
  331.   const char *cap_mode;        /* cap mode */
  332.   int cap_type;            /* one of CAP_*, determined by cap mode */
  333.   const char *join_mode;    /* join mode */
  334.   int join_type;        /* one of JOIN_*, determined by join mode */
  335.   double miter_limit;        /* miter limit for line joins */
  336.   double line_width;        /* width of lines in user coordinates */
  337.   bool line_width_is_default;    /* line width is (Plotter-specific) default? */
  338.   double device_line_width;    /* line width in device coordinates */
  339.   int quantized_device_line_width; /* line width, quantized to integer */
  340.   const double *dash_array;    /* array of dash on/off lengths (nonnegative)*/
  341.   int dash_array_len;        /* length of same */
  342.   double dash_offset;        /* offset distance into dash array (`phase') */
  343.   bool dash_array_in_effect;    /* dash array should override line mode? */
  344.   int pen_type;            /* pen type (0 = no pen, 1 = pen) */
  345.   int fill_type;        /* fill type (0 = no fill, 1 = fill, ...) */
  346.   int orientation;            /* orientation of circles etc.(1=c'clockwise)*/
  347.   /* 2. text-related attributes */
  348.   const char *font_name;    /* font name */
  349.   double font_size;        /* font size in user coordinates */
  350.   bool font_size_is_default;    /* font size is (Plotter-specific) default? */
  351.   double text_rotation;        /* degrees counterclockwise, for labels */
  352.   const char *true_font_name;    /* true font name (as retrieved) */
  353.   double true_font_size;    /* true font size (as retrieved) */
  354.   double font_ascent;        /* font ascent (as retrieved) */
  355.   double font_descent;        /* font descent (as retrieved) */
  356.   double font_cap_height;    /* font capital height (as received) */
  357.   int font_type;        /* F_{HERSHEY|POSTSCRIPT|PCL|STICK|OTHER} */
  358.   int typeface_index;        /* typeface index (in g_fontdb.h table) */
  359.   int font_index;        /* font index, within typeface */
  360.   bool font_is_iso8859_1;    /* whether font uses iso8859_1 encoding */
  361.   /* 3. color attributes (fgcolor and fillcolor are path-related; fgcolor
  362.      affects other primitives too) */
  363.   plColor fgcolor;        /* foreground color, i.e., pen color */
  364.   plColor fillcolor_base;    /* fill color (not affected by fill_type) */
  365.   plColor fillcolor;        /* fill color (takes fill_type into account) */
  366.   plColor bgcolor;        /* background color for graphics display */
  367.   bool bgcolor_suppressed;    /* no actual background color? */
  368.  
  369. /* default values for certain attributes, used when an out-of-range value
  370.    is requested (these two are special because they're set by fsetmatrix()) */
  371.   double default_line_width;    /* width of lines in user coordinates */
  372.   double default_font_size;    /* font size in user coordinates */
  373.  
  374. /****************** DEVICE-DEPENDENT PART ***************************/
  375.  
  376. /* elements specific to the HPGL Plotter drawing state */
  377.   double hpgl_pen_width;    /* pen width (frac of diag dist betw P1,P2) */
  378.  
  379. /* elements specific to the Fig Plotter drawing state */
  380.   int fig_font_point_size;    /* font size in fig's idea of points */
  381.   int fig_fill_level;        /* fig's fill level */
  382.   int fig_fgcolor;        /* fig's foreground color */
  383.   int fig_fillcolor;        /* fig's fill color */
  384.  
  385. /* elements specific to the PS Plotter drawing state */
  386.   double ps_fgcolor_red;    /* RGB for fgcolor, each in [0.0,1.0] */
  387.   double ps_fgcolor_green;
  388.   double ps_fgcolor_blue;
  389.   double ps_fillcolor_red;    /* RGB for fillcolor, each in [0.0,1.0] */
  390.   double ps_fillcolor_green;
  391.   double ps_fillcolor_blue;
  392.   int ps_idraw_fgcolor;        /* index of idraw fgcolor in table */
  393.   int ps_idraw_bgcolor;        /* index of idraw bgcolor in table */
  394.   int ps_idraw_shading;        /* index of idraw shading in table */
  395.  
  396. /* elements specific to the GIF Plotter drawing state */
  397.   plColor i_pen_color;        /* pen color (24-bit RGB) */
  398.   plColor i_fill_color;        /* fill color (24-bit RGB) */
  399.   plColor i_bg_color;        /* background color (24-bit RGB) */
  400.   unsigned char i_pen_color_index; /* pen color index */
  401.   unsigned char i_fill_color_index; /* fill color index */
  402.   unsigned char i_bg_color_index; /* bg color index */
  403.   bool i_pen_color_status;    /* foreground color index is genuine? */
  404.   bool i_fill_color_status;    /* fill color index is genuine? */
  405.   bool i_bg_color_status;    /* background color index is genuine? */
  406.  
  407. #ifndef X_DISPLAY_MISSING
  408. /* elements specific to the X Drawable Plotter drawing state */
  409.   double x_font_pixmatrix[4];    /* pixel matrix, parsed from font name */
  410.   bool x_native_positioning;    /* if set, can use XDrawString() etc. */
  411.   XFontStruct *x_font_struct;    /* font structure (used in x_text.c) */
  412.   const unsigned char *x_label;    /* label (hint to _x_retrieve_font()) */
  413.   GC x_gc_fg;            /* graphics context, for drawing */
  414.   GC x_gc_fill;            /* graphics context, for filling */
  415.   GC x_gc_bg;            /* graphics context, for erasing */
  416.   plColor x_current_fgcolor;    /* pen color stored in GC (48-bit RGB) */
  417.   plColor x_current_fillcolor;    /* fill color stored in GC (48-bit RGB) */
  418.   plColor x_current_bgcolor;    /* bg color stored in GC (48-bit RGB) */
  419.   unsigned long x_gc_fgcolor;    /* color stored in drawing GC (pixel value) */
  420.   unsigned long x_gc_fillcolor;    /* color stored in filling GC (pixel value) */
  421.   unsigned long x_gc_bgcolor;    /* color stored in erasing GC (pixel value) */
  422.   bool x_gc_fgcolor_status;    /* pixel value in drawing GC is genuine? */
  423.   bool x_gc_fillcolor_status;    /* pixel value in filling GC is genuine? */
  424.   bool x_gc_bgcolor_status;    /* pixel value in erasing GC is genuine? */
  425.   int x_gc_line_style;        /* line style stored in drawing GC */
  426.   int x_gc_cap_style;        /* cap style stored in drawing GC */
  427.   int x_gc_join_style;        /* join style stored in drawing GC */
  428.   int x_gc_line_width;        /* line width stored in drawing GC */
  429.   const char *x_gc_dash_list;    /* dash list stored in drawing GC */
  430.   int x_gc_dash_list_len;    /* length of dash list stored in drawing GC */
  431.   int x_gc_dash_offset;        /* offset into dash sequence, in drawing GC */
  432.   int x_gc_fill_rule;        /* fill rule stored in filling GC */
  433. #endif /* not X_DISPLAY_MISSING */
  434.  
  435. /* pointer to previous drawing state */
  436.   struct plDrawStateStruct *previous;
  437.  
  438. } plDrawState;
  439.  
  440.  
  441. /**********************************************************************/
  442.  
  443. /* An output buffer that may easily be resized.  Used by most Plotters that
  444.    do not do real-time output, to store device code for all graphical
  445.    objects plotted on a page, and page-specific data such as the bounding
  446.    box and `fonts used' information.  (See e.g. g_outbuf.c.)  Plotters that
  447.    wait until they are deleted before outputing graphics, e.g. PSPlotters
  448.    and CGMPlotters, maintain not just one of these things but rather a
  449.    linked list, one output buffer per page. */
  450.  
  451. /* NUM_PS_FONTS and NUM_PCL_FONTS should agree with the number of fonts of
  452.    each type in g_fontdb.c.  These are also defined in libplot/extern.h. */
  453. #define NUM_PS_FONTS 35
  454. #define NUM_PCL_FONTS 45
  455.  
  456. typedef struct plOutbufStruct
  457. {
  458.   /* if non-NULL, a plOutbuf containing a page header */
  459.   struct plOutbufStruct *header;
  460.  
  461.   /* if non-NULL, a plOutbuf containing a page trailer */
  462.   struct plOutbufStruct *trailer;
  463.  
  464.   /* device code for the graphics on the page */
  465.   char *base;            /* start of buffer */
  466.   unsigned long len;        /* size of buffer */
  467.   char *point;            /* current point (high-water mark) */
  468.   char *reset_point;        /* point below which contents are frozen */
  469.   unsigned long contents;    /* size of contents */
  470.   unsigned long reset_contents;    /* size of frozen contents if any */
  471.  
  472.   /* page-specific information that some Plotters generate and use (this is
  473.      starting to look like a Christmas tree...) */
  474.   double xrange_min;        /* bounding box, in device coordinates */
  475.   double xrange_max;
  476.   double yrange_min;
  477.   double yrange_max;
  478.   bool ps_font_used[NUM_PS_FONTS]; /* PS fonts used on page */
  479.   bool pcl_font_used[NUM_PCL_FONTS]; /* PCL fonts used on page */
  480.   plColor bg_color;        /* background color for the page */
  481.   bool bg_color_suppressed;    /* background color is "none"? */
  482.  
  483.   /* a hook for Plotters to hang other page-specific data */
  484.   voidptr_t extra;
  485.  
  486.   /* pointer to previous Outbuf in page list if any */
  487.   struct plOutbufStruct *next;
  488. } plOutbuf;
  489.  
  490. /* Each Plotter caches the color names that have previously been mapped to
  491.    RGB triples via libplot's colorname database (see g_colorname.h).
  492.    For the cache, a linked list is currently used. */
  493.  
  494. typedef struct
  495. {
  496.   const char *name;
  497.   unsigned char red;
  498.   unsigned char green;
  499.   unsigned char blue;
  500. } plColorNameInfo;
  501.  
  502. typedef struct plCachedColorNameInfoStruct
  503. {
  504.   const plColorNameInfo *info;
  505.   struct plCachedColorNameInfoStruct *next;
  506. } plCachedColorNameInfo;
  507.  
  508. typedef struct
  509. {
  510.   plCachedColorNameInfo *cached_colors;    /* head of linked list */
  511. } plColorNameCache;
  512.  
  513. #ifndef X_DISPLAY_MISSING
  514. /* Each X DrawablePlotter (or X Plotter) keeps track of which fonts have
  515.    been request from an X server, in any connection, by constructing a
  516.    linked list of these records.  A linked list is good enough if we don't
  517.    have huge numbers of font changes. */
  518. typedef struct plFontRecordStruct
  519. {
  520.   char *name;            /* font name, preferably an XLFD name */
  521.   XFontStruct *x_font_struct;    /* font structure */
  522.   double true_font_size;
  523.   double font_pixmatrix[4];
  524.   double font_ascent;
  525.   double font_descent;
  526.   double font_cap_height;
  527.   bool native_positioning;
  528.   bool font_is_iso8859_1;
  529.   bool subset;            /* did we retrieve a subset of the font? */
  530.   unsigned char subset_vector[32]; /* 256-bit vector, 1 bit per font char */
  531.   struct plFontRecordStruct *next; /* most recently retrieved font */
  532. } plFontRecord;
  533.  
  534. /* Allocated color cells are kept track of similarly */
  535. typedef struct plColorRecordStruct
  536. {
  537.   XColor rgb;            /* RGB value and pixel value (if any) */
  538.   bool allocated;        /* pixel value successfully allocated? */
  539.   int frame_number;        /* frame that cell was most recently used in*/
  540.   int page_number;        /* page that cell was most recently used in*/
  541.   struct plColorRecordStruct *next; /* most recently retrieved color cell */
  542. } plColorRecord;
  543. #endif /* not X_DISPLAY_MISSING */
  544.  
  545.  
  546. /***********************************************************************/
  547.  
  548. /* The Plotter class, and also its derived classes (in libplotter).  In
  549.    libplot, a Plotter is a struct, and there are no derived classes; the
  550.    data members of the derived classes are located inside the Plotter
  551.    structure. */
  552.  
  553. /* A few miscellaneous constants that appear in the declaration of the
  554.    Plotter class (should be moved elsewhere if possible). */
  555.  
  556. /* Number of recognized Plotter parameters (see g_params2.c). */
  557. #define NUM_PLOTTER_PARAMETERS 33
  558.  
  559. /* Maximum number of pens, or logical pens, for an HP-GL/2 device.  Some
  560.    such devices permit as many as 256, but all should permit at least 32.
  561.    Our pen numbering will range over 0..HPGL2_MAX_NUM_PENS-1. */
  562. #define HPGL2_MAX_NUM_PENS 32
  563.  
  564. /* Maximum number of non-builtin colors that can be specified in an xfig
  565.    input file.  See also FIG_NUM_STD_COLORS, defined in
  566.    libplot/extern.h. */
  567. #define FIG_MAX_NUM_USER_COLORS 512
  568.  
  569. /* Supported Plotter types.  These values are used in a `tag field', in
  570.    libplot but not libplotter.  (C++ doesn't have such things, at least it
  571.    didn't until RTTI was invented :-)). */
  572. #ifdef NOT_LIBPLOTTER
  573. typedef enum 
  574. {
  575.   PL_GENERIC,            /* instance of base Plotter class */
  576.   PL_BITMAP,            /* bitmap class, derived from by PNM and PNG */
  577.   PL_META,            /* GNU graphics metafile */
  578.   PL_TEK,            /* Tektronix 4014 with EGM */
  579.   PL_REGIS,            /* ReGIS (remote graphics instruction set) */
  580.   PL_HPGL,            /* HP-GL and HP-GL/2 */
  581.   PL_PCL,            /* PCL 5 (i.e. HP-GL/2 w/ header, trailer) */
  582.   PL_FIG,            /* xfig 3.2 */
  583.   PL_CGM,            /* CGM (Computer Graphics Metafile) */
  584.   PL_PS,            /* Postscript, with idraw support */
  585.   PL_AI,            /* Adobe Illustrator 5 (or 3) */
  586.   PL_SVG,            /* Scalable Vector Graphics */
  587.   PL_GIF,            /* GIF 87a or 89a */
  588.   PL_PNM            /* Portable Anymap Format (PBM/PGM/PPM) */
  589. #ifdef INCLUDE_PNG_SUPPORT
  590.   , PL_PNG            /* PNG: Portable Network Graphics */
  591. #endif
  592. #ifndef X_DISPLAY_MISSING
  593.   , PL_X11_DRAWABLE        /* X11 Drawable */
  594.   , PL_X11            /* X11 (pops up, manages own window[s]) */
  595. #endif
  596. } plPlotterTag;
  597. #endif /* NOT_LIBPLOTTER */
  598.  
  599. /* Types of Plotter output model.  The `output_model' data element in any
  600.    Plotter class specifies the output model, and the libplot machinery
  601.    takes it from there.  In particular, plOutbuf structures (one per page)
  602.    are maintained if necessary, and written out at the appropriate time.
  603.  
  604.    Note: in the PAGES_ALL_AT_ONCE, OUTPUT_VIA_CUSTOM_ROUTINES* cases, the
  605.    Plotter is responsible for managing its own output.  In the
  606.    PAGES_ALL_AT_ONCE case, libplot maintains not just one but an entire
  607.    linked list of plOutbuf's, to be scanned over by the derived Plotter at
  608.    deletion time. */
  609.  
  610. typedef enum 
  611. {
  612.   PL_OUTPUT_NONE,
  613.   /* No output at all; Plotter is used primarily for subclassing.  E.g.,
  614.      generic and Bitmap Plotters. */
  615.  
  616.   PL_OUTPUT_ONE_PAGE,
  617.   /* Plotter produces at most one page of output (the first), and uses
  618.      libplot's builtin plOutbuf-based output mechanism.  The first page,
  619.      which is written to a plOutbuf, is written out by the first invocation
  620.      of closepl(), and all later pages are ignored.  E.g., Fig,
  621.      Illustrator, and SVG Plotters. */
  622.  
  623.   PL_OUTPUT_ONE_PAGE_AT_A_TIME,
  624.   /* Plotter produces any number of pages of output, and uses libplot's
  625.      builtin plOutbuf-based output mechanism.  Each page is written out as
  626.      soon as closepl() is called on it.  E.g., HP-GL/PCL Plotters.  */
  627.  
  628.   PL_OUTPUT_PAGES_ALL_AT_ONCE,
  629.   /* Plotter produces any number of pages of output, and uses libplot's
  630.      builtin plOutbuf-based output mechanism.  But pages are written out
  631.      only when the Plotter is deleted, i.e., when the internal terminate()
  632.      function is called.  (Actually, it's the generic-class terminate(),
  633.      which any derived-class terminate() calls, that does it.)  Because all
  634.      pages need to be stored, a linked list of plOutbuf's is created, one
  635.      per page.  E.g., PS and CGM Plotters.  */
  636.  
  637.   PL_OUTPUT_VIA_CUSTOM_ROUTINES,
  638.   /* Plotter uses its own output routines to write one or possibly more
  639.      pages to its output stream, as whole pages (i.e., when closepl() is
  640.      called).  It doesn't use libplot's plOutbuf-based output routines.
  641.      E.g., PNM, GIF, and PNG Plotters (all of which output only 1 page). */
  642.  
  643.   PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME,
  644.   /* Plotter uses its own output routines to write to its output stream, in
  645.      real time.  It doesn't use libplot's plOutbuf-based output routines.
  646.      E.g., Metafile, Tektronix, and ReGIS Plotters. */
  647.  
  648.   PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM
  649.   /* Plotter uses its own output routines to write to something other than
  650.      an output stream, which must presumably be passed to it as a Plotter
  651.      parameter.  May or may not plot in real time.  E.g., X Drawable and X
  652.      Plotters (both of which plot in real time). */
  653. } plPlotterOutputModel;
  654.  
  655. /* Plotter data.  These data members of any Plotter object are stuffed into
  656.    a single struct, for convenience.  Most of them are initialized by the
  657.    initialize() method, and don't change thereafter.  So they're really
  658.    parameters: they define the functioning of any Plotter.
  659.    
  660.    A few of these, e.g. the `page' member, do change at later times.  But
  661.    it's the core Plotter code that changes them; not the device-specific
  662.    drivers.  They're flagged by D: (i.e. dynamic), in their description. */
  663.  
  664. typedef struct
  665. {
  666.   /* data members (a great many!) which are really Plotter parameters */
  667.  
  668. #ifdef NOT_LIBPLOTTER
  669.   /* tag field */
  670.   plPlotterTag type;        /* Plotter type: one of PL_* defined above */
  671. #endif /* NOT_LIBPLOTTER */
  672.  
  673.   /* low-level I/O issues */
  674.   plPlotterOutputModel output_model;/* one of PL_OUTPUT_* (see above) */
  675.   FILE *infp;            /* stdio-style input stream if any */
  676.   FILE *outfp;            /* stdio-style output stream if any */
  677.   FILE *errfp;            /* stdio-style error stream if any */
  678. #ifndef NOT_LIBPLOTTER
  679.   istream *instream;        /* C++-style input stream if any */
  680.   ostream *outstream;        /* C++-style output stream if any */
  681.   ostream *errstream;        /* C++-style error stream if any */
  682. #endif /* not NOT_LIBPLOTTER */
  683.  
  684.   /* device driver parameters (i.e., instance copies of class variables) */
  685.   voidptr_t params[NUM_PLOTTER_PARAMETERS];
  686.  
  687.   /* (mostly) user-queryable capabilities: 0/1/2 = no/yes/maybe */
  688.   int have_wide_lines;    
  689.   int have_dash_array;
  690.   int have_solid_fill;
  691.   int have_odd_winding_fill;
  692.   int have_nonzero_winding_fill;
  693.   int have_settable_bg;
  694.   int have_escaped_string_support; /* can plot labels containing escapes? */
  695.   int have_ps_fonts;
  696.   int have_pcl_fonts;
  697.   int have_stick_fonts;
  698.   int have_extra_stick_fonts;
  699.   int have_other_fonts;
  700.  
  701.   /* text and font-related parameters (internal, not queryable by user) */
  702.   int default_font_type;    /* F_{HERSHEY|POSTSCRIPT|PCL|STICK} */
  703.   bool pcl_before_ps;        /* PCL fonts searched first? (if applicable) */
  704.   bool have_horizontal_justification; /*device can justify text horizontally?*/
  705.   bool have_vertical_justification; /* device can justify text vertically? */
  706.   bool kern_stick_fonts;      /* device kerns variable-width HP vector fonts?*/
  707.   bool issue_font_warning;    /* issue warning on font substitution? */
  708.  
  709.   /* path-related parameters (also internal) */
  710.   int max_unfilled_path_length; /* user-settable, for unfilled polylines */
  711.   bool have_mixed_paths;    /* can mix arcs/Beziers and lines in paths? */
  712.   plScalingType allowed_arc_scaling; /* scaling allowed for circular arcs */
  713.   plScalingType allowed_ellarc_scaling;    /* scaling allowed for elliptic arcs */
  714.   plScalingType allowed_quad_scaling; /*scaling allowed for quadratic Beziers*/
  715.   plScalingType allowed_cubic_scaling; /* scaling allowed for cubic Beziers */
  716.   plScalingType allowed_box_scaling; /* scaling allowed for boxes */
  717.   plScalingType allowed_circle_scaling; /* scaling allowed for circles */
  718.   plScalingType allowed_ellipse_scaling; /* scaling allowed for ellipses */
  719.  
  720.   /* color-related parameters (also internal) */
  721.   bool emulate_color;        /* emulate color by grayscale? */
  722.  
  723.   /* cache of previously retrieved color names (used for speed) */
  724.   plColorNameCache *color_name_cache;/* pointer to color name cache */
  725.  
  726.   /* info on the device coordinate frame (ranges for viewport in terms of
  727.      native device coordinates, etc.; note that if flipped_y=true, then
  728.      jmax<jmin or ymax<ymin) */
  729.   int display_model_type;    /* one of DISP_MODEL_{PHYSICAL,VIRTUAL} */
  730.   int display_coors_type;    /* one of DISP_DEVICE_COORS_{REAL, etc.} */
  731.   bool flipped_y;        /* y increases downward? */
  732.   int imin, imax, jmin, jmax;    /* ranges, if virtual with integer coors */
  733.   double xmin, xmax, ymin, ymax; /* ranges, if physical with real coors */
  734.  
  735.   /* low-level page and viewport information, if display is physical.
  736.      Final six parameters are in terms of inches, and can be specified by
  737.      setting the PAGESIZE Plotter parameter. */
  738.   const plPageData *page_data;    /* page dimensions and other characteristics */
  739.   double viewport_xsize, viewport_ysize; /* viewport dimensions (inches) */
  740.   double viewport_xorigin, viewport_yorigin; /* viewport origin (inches) */
  741.   double viewport_xoffset, viewport_yoffset; /* viewport origin offset */
  742.  
  743.   /* affine transformation from NDC to device coordinates */
  744.   double m_ndc_to_device[6];    /*  1. a linear transformation (4 elements)
  745.                       2. a translation (2 elements) */
  746.  
  747. /* dynamic data members, which are updated during Plotter operation, unlike
  748.    the many data members above */
  749.  
  750.   bool open;            /* D: whether or not Plotter is open */
  751.   bool opened;            /* D: whether or not Plotter has been opened */
  752.   int page_number;        /* D: number of times it has been opened */
  753.   bool fontsize_invoked;    /* D: fontsize() invoked on this page? */
  754.   bool linewidth_invoked;    /* D: linewidth() invoked on this page? */
  755.   int frame_number;        /* D: number of frame in page */
  756.  
  757.   /* whether warning messages have been issued */
  758.   bool font_warning_issued;    /* D: issued warning on font substitution */
  759.   bool pen_color_warning_issued; /* D: issued warning on name substitution */
  760.   bool fill_color_warning_issued; /* D: issued warning on name substitution */
  761.   bool bg_color_warning_issued;    /* D: issued warning on name substitution */
  762.  
  763.   /* pointers to output buffers, containing graphics code */
  764.   plOutbuf *page;        /* D: output buffer for current page */
  765.   plOutbuf *first_page;        /* D: first page (if a linked list is kept) */
  766.  
  767. } plPlotterData;
  768.  
  769. /* The macro P___ elides argument prototypes if the compiler is a pre-ANSI
  770.    C compiler that does not support them. */
  771. #ifdef P___
  772. #undef P___
  773. #endif
  774. #if defined (__STDC__) || defined (_AIX) \
  775.     || (defined (__mips) && defined (_SYSTYPE_SVR4)) \
  776.     || defined(WIN32) || defined(__cplusplus)
  777. #define P___(protos) protos
  778. #else
  779. #define P___(protos) ()
  780. #endif
  781.  
  782. /* The macro Q___ is used for declaring Plotter methods (as function
  783.    pointers for libplot, and as function members of the Plotter
  784.    class, for libplotter).  QQ___ is also used for declaring PlotterParams
  785.    methods.  It is the same as Q___, but does not declare the function
  786.    members as virtual (the PlotterParams class is not derived from). */
  787. #ifdef Q___
  788. #undef Q___
  789. #endif
  790. #ifdef NOT_LIBPLOTTER
  791. #define Q___(rettype,f) rettype (*f)
  792. #define QQ___(rettype,f) rettype (*f)
  793. #else  /* LIBPLOTTER */
  794. #define Q___(rettype,f) virtual rettype f
  795. #define QQ___(rettype,f) rettype f
  796. #endif
  797.  
  798. /* Methods of the Plotter class (and derived classes) all have a hidden
  799.    argument, called `this', which is a pointer to the invoking Plotter
  800.    instance.  That's a standard C++ convention.  In libplot, we must pass
  801.    such a pointer explicitly, as an extra argument; we call it `_plotter'.
  802.    In libplotter, each occurrence of `_plotter' in the body of a Plotter
  803.    method is mapped to `this'.
  804.  
  805.    Since the same code is used for both libplot and libplotter, we use a
  806.    macro, R___() or S___(), in the declaration and the definition of each
  807.    Plotter method.  In libplotter, they elide their arguments.  But in
  808.    libplot, they do not; also, R___() appends a comma.
  809.  
  810.    Methods of the PlotterParams helper class are handled similarly.  In
  811.    libplot, each of them has an extra argument, `_plotter_params'.  This is
  812.    arranged via R___() or S___().  In libplotter, each occurrence of
  813.    `_plotter_params' in the body of a PlotterParams method is mapped to
  814.    `this'. */
  815.  
  816. #ifdef NOT_LIBPLOTTER
  817. #define R___(arg1) arg1,
  818. #define S___(arg1) arg1
  819. #else  /* LIBPLOTTER */
  820. #define _plotter this
  821. #define _plotter_params this
  822. #define R___(arg1)
  823. #define S___(arg1)
  824. #endif
  825.  
  826. /* The PlotterParams class (or struct) definition.  This is a helper class.
  827.    Any instance of it holds parameters that are used when instantiating the
  828.    Plotter class.  */
  829.  
  830. #ifndef NOT_LIBPLOTTER
  831. class PlotterParams
  832. #else
  833. typedef struct plPlotterParamsStruct /* this tag is used only by libplot */
  834. #endif
  835. {
  836. #ifndef NOT_LIBPLOTTER
  837.  public:
  838.   /* PlotterParams CTORS AND DTOR; copy constructor, assignment operator */
  839.   PlotterParams ();
  840.   ~PlotterParams ();
  841.   PlotterParams (const PlotterParams& oldPlotterParams);
  842.   PlotterParams& operator= (const PlotterParams& oldPlotterParams);
  843. #endif
  844.  
  845.   /* PLOTTERPARAMS PUBLIC METHODS */
  846.   QQ___(int,setplparam) P___((R___(struct plPlotterParamsStruct *_plotter_params) const char *parameter, voidptr_t value));
  847.  
  848.   /* PUBLIC DATA: user-specified (recognized) Plotter parameters */
  849.   voidptr_t plparams[NUM_PLOTTER_PARAMETERS];
  850. }
  851. #ifdef NOT_LIBPLOTTER
  852. PlotterParams;
  853. #else  /* not NOT_LIBPLOTTER */
  854. ;
  855. #endif /* not NOT_LIBPLOTTER */
  856.  
  857. /* The Plotter class (or struct) definition.  There are many members! */
  858.  
  859. #ifndef NOT_LIBPLOTTER
  860. class Plotter
  861. #else
  862. typedef struct plPlotterStruct    /* this tag is used only by libplot */
  863. #endif
  864. {
  865. #ifndef NOT_LIBPLOTTER
  866.  private:
  867.   /* disallow copying and assignment */
  868.   Plotter (const Plotter& oldplotter);  
  869.   Plotter& operator= (const Plotter& oldplotter);
  870.  
  871.   /* Private functions related to the drawing of text strings in Hershey
  872.      fonts (all defined in g_alab_her.c).  In libplot they're declared in
  873.      libplot/extern.h.  */
  874.   double _alabel_hershey (const unsigned char *s, int x_justify, int y_justify);
  875.   double _flabelwidth_hershey (const unsigned char *s);
  876.   void _draw_hershey_glyph (int num, double charsize, int type, bool oblique);
  877.   void _draw_hershey_penup_stroke (double dx, double dy, double charsize, bool oblique);
  878.   void _draw_hershey_string (const unsigned short *string);
  879.   void _draw_hershey_stroke (bool pendown, double deltax, double deltay);
  880.  
  881.   /* Other private functions (a mixed bag).  In libplot they're declared
  882.      in libplot/extern.h. */
  883.   double _render_non_hershey_string (const char *s, bool do_render, int x_justify, int y_justify);
  884.   double _render_simple_string (const unsigned char *s, bool do_render, int h_just, int v_just);
  885.   unsigned short * _controlify (const unsigned char *);
  886.   void _copy_params_to_plotter (const PlotterParams *params);
  887.   void _create_first_drawing_state (void);
  888.   void _delete_first_drawing_state (void);
  889.   void _free_params_in_plotter (void);
  890.   void _maybe_replace_arc (void);
  891.   void _set_font (void);
  892.  
  893.  public:
  894.   /* PLOTTER CTORS (old-style, not thread-safe) */
  895.   Plotter (FILE *infile, FILE *outfile, FILE *errfile);
  896.   Plotter (FILE *outfile);
  897.   Plotter (istream& in, ostream& out, ostream& err);
  898.   Plotter (ostream& out);
  899.   Plotter ();
  900.   /* PLOTTER CTORS (new-style, thread-safe) */
  901.   Plotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  902.   Plotter (FILE *outfile, PlotterParams ¶ms);
  903.   Plotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  904.   Plotter (ostream& out, PlotterParams ¶ms);
  905.   Plotter (PlotterParams ¶ms);
  906.   /* PLOTTER DTOR */
  907.   virtual ~Plotter ();
  908.  
  909.   /* PLOTTER PUBLIC METHOD (static, used by old [non-thread-safe] bindings) */
  910.   static int parampl (const char *parameter, voidptr_t value);
  911.  
  912.   /* PLOTTER PUBLIC METHODS.
  913.  
  914.      The methods in the libplot/libplotter API.  The QQ___() and other
  915.      macros fix things so that in libplotter, these are declared as
  916.      non-virtual Plotter class methods.  The macros are now unnecessary,
  917.      because in libplot, the methods are declared not here, but in
  918.      extern.h.
  919.  
  920.      Note that in the code, these Plotter methods appear under the names
  921.      _API_alabel() etc.  Via #define's in extern.h, they're renamed as
  922.      _pl_alable_r() etc. in libplot, and as Plotter::alabel etc. in
  923.      libplotter. */
  924.  
  925.   QQ___(int,alabel) P___((R___(struct plPlotterStruct *_plotter) int x_justify, int y_justify, const char *s));
  926.   QQ___(int,arc) P___((R___(struct plPlotterStruct *_plotter) int xc, int yc, int x0, int y0, int x1, int y1));
  927.   QQ___(int,arcrel) P___((R___(struct plPlotterStruct *_plotter) int dxc, int dyc, int dx0, int dy0, int dx1, int dy1));
  928.   QQ___(int,bezier2) P___((R___(struct plPlotterStruct *_plotter) int x0, int y0, int x1, int y1, int x2, int y2));
  929.   QQ___(int,bezier2rel) P___((R___(struct plPlotterStruct *_plotter) int dx0, int dy0, int dx1, int dy1, int dx2, int dy2));
  930.   QQ___(int,bezier3) P___((R___(struct plPlotterStruct *_plotter) int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3));
  931.   QQ___(int,bezier3rel) P___((R___(struct plPlotterStruct *_plotter) int dx0, int dy0, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3));
  932.   QQ___(int,bgcolor) P___((R___(struct plPlotterStruct *_plotter) int red, int green, int blue));
  933.   QQ___(int,bgcolorname) P___((R___(struct plPlotterStruct *_plotter) const char *name));
  934.   QQ___(int,box) P___((R___(struct plPlotterStruct *_plotter) int x0, int y0, int x1, int y1));
  935.   QQ___(int,boxrel) P___((R___(struct plPlotterStruct *_plotter) int dx0, int dy0, int dx1, int dy1));
  936.   QQ___(int,capmod) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  937.   QQ___(int,circle) P___((R___(struct plPlotterStruct *_plotter) int x, int y, int r));
  938.   QQ___(int,circlerel) P___((R___(struct plPlotterStruct *_plotter) int dx, int dy, int r));
  939.   QQ___(int,closepath) P___((S___(struct plPlotterStruct *_plotter)));
  940.   QQ___(int,closepl) P___((S___(struct plPlotterStruct *_plotter)));
  941.   QQ___(int,color) P___((R___(struct plPlotterStruct *_plotter) int red, int green, int blue));
  942.   QQ___(int,colorname) P___((R___(struct plPlotterStruct *_plotter) const char *name));
  943.   QQ___(int,cont) P___((R___(struct plPlotterStruct *_plotter) int x, int y));
  944.   QQ___(int,contrel) P___((R___(struct plPlotterStruct *_plotter) int dx, int dy));
  945.   QQ___(int,ellarc) P___((R___(struct plPlotterStruct *_plotter) int xc, int yc, int x0, int y0, int x1, int y1));
  946.   QQ___(int,ellarcrel) P___((R___(struct plPlotterStruct *_plotter) int dxc, int dyc, int dx0, int dy0, int dx1, int dy1));
  947.   QQ___(int,ellipse) P___((R___(struct plPlotterStruct *_plotter) int x, int y, int rx, int ry, int angle));
  948.   QQ___(int,ellipserel) P___((R___(struct plPlotterStruct *_plotter) int dx, int dy, int rx, int ry, int angle));
  949.   QQ___(int,endpath) P___((S___(struct plPlotterStruct *_plotter)));
  950.   QQ___(int,endsubpath) P___((S___(struct plPlotterStruct *_plotter)));
  951.   QQ___(int,erase) P___((S___(struct plPlotterStruct *_plotter)));
  952.   QQ___(int,farc) P___((R___(struct plPlotterStruct *_plotter) double xc, double yc, double x0, double y0, double x1, double y1));
  953.   QQ___(int,farcrel) P___((R___(struct plPlotterStruct *_plotter) double dxc, double dyc, double dx0, double dy0, double dx1, double dy1));
  954.   QQ___(int,fbezier2) P___((R___(struct plPlotterStruct *_plotter) double x0, double y0, double x1, double y1, double x2, double y2));
  955.   QQ___(int,fbezier2rel) P___((R___(struct plPlotterStruct *_plotter) double dx0, double dy0, double dx1, double dy1, double dx2, double dy2));
  956.   QQ___(int,fbezier3) P___((R___(struct plPlotterStruct *_plotter) double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3));
  957.   QQ___(int,fbezier3rel) P___((R___(struct plPlotterStruct *_plotter) double dx0, double dy0, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3));
  958.   QQ___(int,fbox) P___((R___(struct plPlotterStruct *_plotter) double x0, double y0, double x1, double y1));
  959.   QQ___(int,fboxrel) P___((R___(struct plPlotterStruct *_plotter) double dx0, double dy0, double dx1, double dy1));
  960.   QQ___(int,fcircle) P___((R___(struct plPlotterStruct *_plotter) double x, double y, double r));
  961.   QQ___(int,fcirclerel) P___((R___(struct plPlotterStruct *_plotter) double dx, double dy, double r));
  962.   QQ___(int,fconcat) P___((R___(struct plPlotterStruct *_plotter) double m0, double m1, double m2, double m3, double m4, double m5));
  963.   QQ___(int,fcont) P___((R___(struct plPlotterStruct *_plotter) double x, double y));
  964.   QQ___(int,fcontrel) P___((R___(struct plPlotterStruct *_plotter) double dx, double dy));
  965.   QQ___(int,fellarc) P___((R___(struct plPlotterStruct *_plotter) double xc, double yc, double x0, double y0, double x1, double y1));
  966.   QQ___(int,fellarcrel) P___((R___(struct plPlotterStruct *_plotter) double dxc, double dyc, double dx0, double dy0, double dx1, double dy1));
  967.   QQ___(int,fellipse) P___((R___(struct plPlotterStruct *_plotter) double x, double y, double rx, double ry, double angle));
  968.   QQ___(int,fellipserel) P___((R___(struct plPlotterStruct *_plotter) double dx, double dy, double rx, double ry, double angle));
  969.   QQ___(double,ffontname) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  970.   QQ___(double,ffontsize) P___((R___(struct plPlotterStruct *_plotter) double size));
  971.   QQ___(int,fillcolor) P___((R___(struct plPlotterStruct *_plotter) int red, int green, int blue));
  972.   QQ___(int,fillcolorname) P___((R___(struct plPlotterStruct *_plotter) const char *name));
  973.   QQ___(int,fillmod) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  974.   QQ___(int,filltype) P___((R___(struct plPlotterStruct *_plotter) int level));
  975.   QQ___(double,flabelwidth) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  976.   QQ___(int,fline) P___((R___(struct plPlotterStruct *_plotter) double x0, double y0, double x1, double y1));
  977.   QQ___(int,flinedash) P___((R___(struct plPlotterStruct *_plotter) int n, const double *dashes, double offset));
  978.   QQ___(int,flinerel) P___((R___(struct plPlotterStruct *_plotter) double dx0, double dy0, double dx1, double dy1));
  979.   QQ___(int,flinewidth) P___((R___(struct plPlotterStruct *_plotter) double size));
  980.   QQ___(int,flushpl) P___((S___(struct plPlotterStruct *_plotter)));
  981.   QQ___(int,fmarker) P___((R___(struct plPlotterStruct *_plotter) double x, double y, int type, double size));
  982.   QQ___(int,fmarkerrel) P___((R___(struct plPlotterStruct *_plotter) double dx, double dy, int type, double size));
  983.   QQ___(int,fmiterlimit) P___((R___(struct plPlotterStruct *_plotter) double limit));
  984.   QQ___(int,fmove) P___((R___(struct plPlotterStruct *_plotter) double x, double y));
  985.   QQ___(int,fmoverel) P___((R___(struct plPlotterStruct *_plotter) double dx, double dy));
  986.   QQ___(int,fontname) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  987.   QQ___(int,fontsize) P___((R___(struct plPlotterStruct *_plotter) int size));
  988.   QQ___(int,fpoint) P___((R___(struct plPlotterStruct *_plotter) double x, double y));
  989.   QQ___(int,fpointrel) P___((R___(struct plPlotterStruct *_plotter) double dx, double dy));
  990.   QQ___(int,frotate) P___((R___(struct plPlotterStruct *_plotter) double theta));
  991.   QQ___(int,fscale) P___((R___(struct plPlotterStruct *_plotter) double x, double y));
  992.   QQ___(int,fsetmatrix) P___((R___(struct plPlotterStruct *_plotter) double m0, double m1, double m2, double m3, double m4, double m5));
  993.   QQ___(int,fspace) P___((R___(struct plPlotterStruct *_plotter) double x0, double y0, double x1, double y1));
  994.   QQ___(int,fspace2) P___((R___(struct plPlotterStruct *_plotter) double x0, double y0, double x1, double y1, double x2, double y2));
  995.   QQ___(double,ftextangle) P___((R___(struct plPlotterStruct *_plotter) double angle));
  996.   QQ___(int,ftranslate) P___((R___(struct plPlotterStruct *_plotter) double x, double y));
  997.   QQ___(int,havecap) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  998.   QQ___(int,joinmod) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  999.   QQ___(int,label) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  1000.   QQ___(int,labelwidth) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  1001.   QQ___(int,line) P___((R___(struct plPlotterStruct *_plotter) int x0, int y0, int x1, int y1));
  1002.   QQ___(int,linedash) P___((R___(struct plPlotterStruct *_plotter) int n, const int *dashes, int offset));
  1003.   QQ___(int,linemod) P___((R___(struct plPlotterStruct *_plotter) const char *s));
  1004.   QQ___(int,linerel) P___((R___(struct plPlotterStruct *_plotter) int dx0, int dy0, int dx1, int dy1));
  1005.   QQ___(int,linewidth) P___((R___(struct plPlotterStruct *_plotter) int size));
  1006.   QQ___(int,marker) P___((R___(struct plPlotterStruct *_plotter) int x, int y, int type, int size));
  1007.   QQ___(int,markerrel) P___((R___(struct plPlotterStruct *_plotter) int dx, int dy, int type, int size));
  1008.   QQ___(int,move) P___((R___(struct plPlotterStruct *_plotter) int x, int y));
  1009.   QQ___(int,moverel) P___((R___(struct plPlotterStruct *_plotter) int dx, int dy));
  1010.   QQ___(int,openpl) P___((S___(struct plPlotterStruct *_plotter)));
  1011.   QQ___(int,orientation) P___((R___(struct plPlotterStruct *_plotter) int direction));
  1012.   QQ___(FILE*,outfile) P___((R___(struct plPlotterStruct *_plotter) FILE* newstream)); /* OBSOLESCENT */
  1013.   QQ___(int,pencolor) P___((R___(struct plPlotterStruct *_plotter) int red, int green, int blue));
  1014.   QQ___(int,pencolorname) P___((R___(struct plPlotterStruct *_plotter) const char *name));
  1015.   QQ___(int,pentype) P___((R___(struct plPlotterStruct *_plotter) int level));
  1016.   QQ___(int,point) P___((R___(struct plPlotterStruct *_plotter) int x, int y));
  1017.   QQ___(int,pointrel) P___((R___(struct plPlotterStruct *_plotter) int dx, int dy));
  1018.   QQ___(int,restorestate) P___((S___(struct plPlotterStruct *_plotter)));
  1019.   QQ___(int,savestate) P___((S___(struct plPlotterStruct *_plotter)));
  1020.   QQ___(int,space) P___((R___(struct plPlotterStruct *_plotter) int x0, int y0, int x1, int y1));
  1021.   QQ___(int,space2) P___((R___(struct plPlotterStruct *_plotter) int x0, int y0, int x1, int y1, int x2, int y2));
  1022.   QQ___(int,textangle) P___((R___(struct plPlotterStruct *_plotter) int angle));
  1023.  
  1024.   /* Undocumented public methods that provide access to the font tables
  1025.      within libplot/libplotter.  They're used by the graphics programs in
  1026.      the plotutils package, to display lists of font names.  In libplot
  1027.      they're declared in libplot/extern.h, rather than here. */
  1028.   voidptr_t get_hershey_font_info P___((S___(struct plPlotterStruct *_plotter)));
  1029.   voidptr_t get_ps_font_info P___((S___(struct plPlotterStruct *_plotter)));
  1030.   voidptr_t get_pcl_font_info P___((S___(struct plPlotterStruct *_plotter)));
  1031.   voidptr_t get_stick_font_info P___((S___(struct plPlotterStruct *_plotter)));
  1032.  
  1033.  protected:
  1034. #endif /* not NOT_LIBPLOTTER */
  1035.  
  1036.   /* PLOTTER PROTECTED METHODS.  All virtual, i.e. they're allowed to be
  1037.      Plotter-specific; the generic versions of these do nothing and are
  1038.      overridden in derived classes, to define what a Plotter does. */
  1039.  
  1040.   /* Initialization (after creation) and termination (before deletion).
  1041.      These are exceptions to the above rule: they're effectively
  1042.      constructors and destructors, so even in the generic Plotter class,
  1043.      they do useful work.  In derived classes they should always invoke
  1044.      their base counterparts. */
  1045.   Q___(void,initialize) P___((S___(struct plPlotterStruct *_plotter)));
  1046.   Q___(void,terminate) P___((S___(struct plPlotterStruct *_plotter)));
  1047.  
  1048.   /* Internal page-related methods, called by the API methods openpl(),
  1049.      erase() and closepl().  `true' return value indicates operation
  1050.      performed successfully. */
  1051.   Q___(bool,begin_page) P___((S___(struct plPlotterStruct *_plotter)));
  1052.   Q___(bool,erase_page) P___((S___(struct plPlotterStruct *_plotter)));
  1053.   Q___(bool,end_page) P___((S___(struct plPlotterStruct *_plotter)));
  1054.  
  1055.   /* Internal `push state' method, called by the API method savestate().
  1056.      This is used by a very few types of Plotter to create or initialize
  1057.      Plotter-specific fields in a newly created drawing state.  Most
  1058.      Plotters don't override the generic version, which simply copies such
  1059.      Plotter-specific fields. */
  1060.   Q___(void,push_state) P___((S___(struct plPlotterStruct *_plotter)));
  1061.  
  1062.   /* Internal `pop state' method, called by the API method restorestate().
  1063.      This is used by a very few types of Plotter to delete or tear down
  1064.      Plotter-specific fields in a drawing state about to be destroyed.
  1065.      Most Plotters don't override the generic version, which does nothing
  1066.      to such fields. */
  1067.   Q___(void,pop_state) P___((S___(struct plPlotterStruct *_plotter)));
  1068.  
  1069.   /* Internal `paint path' method, called when the API method endpath() is
  1070.      invoked, to draw any path that has been built up in a Plotter's
  1071.      drawing state.  It should paint a single simple path.  The generic
  1072.      version of course does nothing. */
  1073.   Q___(void,paint_path) P___((S___(struct plPlotterStruct *_plotter)));
  1074.  
  1075.   /* Another internal method, called by endpath() first, if the path to
  1076.      paint is compound rather than simple.  If the Plotter can paint the
  1077.      compound path, this should return `true'; if `false' is returned,
  1078.      endpath() will paint using compound path emulation instead.  The
  1079.      generic version does nothing, but returns `true'. */
  1080.   Q___(bool,paint_paths) P___((S___(struct plPlotterStruct *_plotter)));
  1081.  
  1082.   /* Support for flushing out the path buffer when it gets too long.  In
  1083.      any Plotter, this predicate is evaluated after any path element is
  1084.      added to the path buffer, provided (1) the path buffer has become
  1085.      greater than or equal to the `max_unfilled_path_length' Plotter
  1086.      parameter, and (2) the path isn't to be filled.  In most Plotters,
  1087.      including generic Plotters, this simply returns `true', to indicate
  1088.      that the path should be flushed out by invoking endpath().  But in
  1089.      Plotters that plot in real time under some circumstances (see below),
  1090.      this normally returns `false' under those circumstances. */
  1091.   Q___(bool,path_is_flushable) P___((S___(struct plPlotterStruct *_plotter)));
  1092.  
  1093.   /* Support for real-time plotting, if desired.  An internal `prepaint
  1094.      segments' method, called not when a path is finished by endpath()
  1095.      being called, but rather when any single segment is added to it.  (Or
  1096.      when several segments, obtained by polygonalizing a higher-level
  1097.      primitive, are added to it.)  Only in Plotters that plot in real time
  1098.      (by definition!) is this not a no-op. */
  1099.   Q___(void,maybe_prepaint_segments) P___((R___(struct plPlotterStruct *_plotter) int prev_num_segments));
  1100.  
  1101.   /* Internal `draw marker' method, called when the API method marker() is
  1102.      invoked.  Only a very few types of Plotter use this.  Return value
  1103.      should indicate whether the marker was drawn; `false' means that a
  1104.      generic drawing routine, which creates a marker from other libplot
  1105.      primitives, should be used.  (Yes, some Plotter output formats support
  1106.      some types of marker but not others!).  The generic version does nothing,
  1107.      but returns `false'. */
  1108.   Q___(bool,paint_marker) P___((R___(struct plPlotterStruct *_plotter) int type, double size));
  1109.  
  1110.   /* Internal `draw point' method, called when the API method point() is
  1111.      invoked.  There's no standard definition of a `point', so Plotters are
  1112.      free to implement this as they see fit. */
  1113.   Q___(void,paint_point) P___((S___(struct plPlotterStruct *_plotter)));
  1114.  
  1115.   /* Internal, Plotter-specific versions of the `alabel' and `flabelwidth'
  1116.      methods, which are applied to single-line text strings in a single
  1117.      font (no escape sequences, etc.).  The API methods alabel and
  1118.      flabelwidth are wrappers around these.
  1119.  
  1120.      The argument h_just specifies the justification to be used when
  1121.      rendering (JUST_LEFT, JUST_RIGHT, or JUST_CENTER).  If a display
  1122.      device provides low-level support for non-default (i.e. non-left)
  1123.      justification, the Plotter's have_horizontal_justification flag (see
  1124.      below) should be set.  Similarly, v_just specifies vertical
  1125.      justification (JUST_TOP, JUST_HALF, JUST_BASE, or JUST_BOTTOM). */
  1126.  
  1127.   /* The first of these is special, for use by Metafile Plotters only.  Any
  1128.      Metafile Plotter has low-level support for drawing labels that include
  1129.      any of our many escape sequences.  (Actually, a Metafile Plotter just
  1130.      dumps them to the output stream, unchanged. :-)).  So the Metafile
  1131.      Plotter class has a special _m_paint_text_string_with_escapes method.
  1132.      In all other Plotters, the paint_text_string_with_escapes method
  1133.      should be set to the dummy _g_paint_text_string_with_escapes method,
  1134.      which does nothing; it'll never be invoked.  Our code recognizes that
  1135.      a Metafile Plotter is special by looking at the Plotter's
  1136.      `have_escaped_string_support' capability, which is `1' for a Metafile
  1137.      Plotter and `0' for all others. */
  1138.  
  1139.   Q___(void,paint_text_string_with_escapes) P___((R___(struct plPlotterStruct *_plotter) const unsigned char *s, int x_justify, int y_justify));
  1140.  
  1141.   Q___(double,paint_text_string) P___((R___(struct plPlotterStruct *_plotter) const unsigned char *s, int h_just, int v_just));
  1142.   Q___(double,get_text_width) P___((R___(struct plPlotterStruct *_plotter) const unsigned char *s));
  1143.  
  1144.   /* Low-level, Plotter-specific `retrieve font' function; called by the
  1145.      internal _set_font() function, which in turn is called by the API
  1146.      methods alabel() and labelwidth(), and by the API methods
  1147.      fontname()/fontsize()/textwidth(), but only because they need to
  1148.      return a font size.  retrieve_font() is called only if the
  1149.      user-specified font is a non-Hershey font.  If it returns false, a
  1150.      default font, e.g., a Hershey font, will be substituted. */
  1151.   Q___(bool,retrieve_font) P___((S___(struct plPlotterStruct *_plotter)));
  1152.  
  1153.   /* Internal `flush output' method, called by the API method flushpl().
  1154.      This is called only if the Plotter does its own output, i.e., does not
  1155.      write to an output stream.  I.e., only if the Plotter's `output_model'
  1156.      data element is PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM.  Return
  1157.      value indicates whether flushing worked. */
  1158.   Q___(bool,flush_output) P___((S___(struct plPlotterStruct *_plotter)));
  1159.  
  1160.   /* error handlers */
  1161.   Q___(void,warning) P___((R___(struct plPlotterStruct *_plotter) const char *msg));
  1162.   Q___(void,error) P___((R___(struct plPlotterStruct *_plotter) const char *msg));
  1163.  
  1164.   /* PLOTTER DATA MEMBERS (not specific to any one device driver).  These
  1165.      are protected rather than private, so they can be accessed by derived
  1166.      classes. */
  1167.  
  1168.   /* Basic data members: many parameters affecting Plotter operation, which
  1169.      are set by the initialize() method and not changed thereafter, plus a
  1170.      few (e.g., pointers to plOutbuf's for holding graphics code) which may
  1171.      change at later times. */
  1172.   plPlotterData *data;
  1173.  
  1174.   /* drawing state stack (pointer to top) */
  1175.   plDrawState *drawstate;
  1176.  
  1177. #ifdef NOT_LIBPLOTTER
  1178.   /* PLOTTER DATA MEMBERS (device driver-specific). */
  1179.   /* In libplot, they appear here, i.e., in the Plotter struct.  But in
  1180.      libplotter, they don't appear here, i.e. they don't appear in the base
  1181.      Plotter class: they appear, more logically, as private or protected
  1182.      data members of the appropriate derived classes (for the definitions
  1183.      of which, see further below in this file). */
  1184.  
  1185.   /* Some of these are constant over the usable lifetime of the Plotter,
  1186.      and are set, at latest, in the first call to begin_page().  They are
  1187.      just parameters.  Other data members may change, since they represent
  1188.      our knowledge of the display device's internal state.  Each of the
  1189.      latter is flagged by "D:" (i.e. "dynamic") in its comment line. */
  1190.  
  1191.   /* data members specific to Bitmap Plotters */
  1192.   voidptr_t b_arc_cache_data;    /* pointer to cache (used by miPolyArc_r) */
  1193.   int b_xn, b_yn;        /* bitmap dimensions */
  1194.   voidptr_t b_painted_set;    /* D: libxmi's canvas (a (miPaintedSet *)) */
  1195.   voidptr_t b_canvas;        /* D: libxmi's canvas (a (miCanvas *)) */
  1196.   /* data members specific to Metafile Plotters */
  1197.   /* 0. parameters */
  1198.   bool meta_portable_output;    /* portable, not binary output format? */
  1199.   /* 1. dynamic attributes, general */
  1200.   plPoint meta_pos;        /* graphics cursor position */
  1201.   bool meta_position_is_unknown; /* position is unknown? */
  1202.   double meta_m_user_to_ndc[6];    /* user->NDC transformation matrix */
  1203.   /* 2. dynamic attributes, path-related */
  1204.   int meta_fill_rule_type;    /* one of FILL_*, determined by fill rule */
  1205.   int meta_line_type;        /* one of L_*, determined by line mode */
  1206.   bool meta_points_are_connected; /* if not set, path displayed as points */
  1207.   int meta_cap_type;        /* one of CAP_*, determined by cap mode */
  1208.   int meta_join_type;        /* one of JOIN_*, determined by join mode */
  1209.   double meta_miter_limit;    /* miter limit for line joins */
  1210.   double meta_line_width;    /* width of lines in user coordinates */
  1211.   bool meta_line_width_is_default; /* line width is default value? */
  1212.   const double *meta_dash_array; /* array of dash on/off lengths(nonnegative)*/
  1213.   int meta_dash_array_len;    /* length of same */
  1214.   double meta_dash_offset;    /* offset distance into dash array (`phase') */
  1215.   bool meta_dash_array_in_effect; /* dash array should override line mode? */
  1216.   int meta_pen_type;        /* pen type (0 = no pen, 1 = pen) */
  1217.   int meta_fill_type;        /* fill type (0 = no fill, 1 = fill, ...) */
  1218.   int meta_orientation;            /* orientation of circles etc.(1=c'clockwise)*/
  1219.   /* 3. dynamic attributes, text-related */
  1220.   const char *meta_font_name;    /* font name */
  1221.   double meta_font_size;    /* font size in user coordinates */
  1222.   bool meta_font_size_is_default; /* font size is Plotter default? */
  1223.   double meta_text_rotation;    /* degrees counterclockwise, for labels */
  1224.   /* 4. dynamic color attributes (fgcolor and fillcolor are path-related;
  1225.      fgcolor affects other primitives too) */
  1226.   plColor meta_fgcolor;        /* foreground color, i.e., pen color */
  1227.   plColor meta_fillcolor_base;    /* fill color */
  1228.   plColor meta_bgcolor;        /* background color for graphics display */
  1229.   /* data members specific to Tektronix Plotters */
  1230.   int tek_display_type;        /* which sort of Tektronix? (one of D_*) */
  1231.   int tek_mode;            /* D: one of MODE_* */
  1232.   int tek_line_type;        /* D: one of L_* */
  1233.   bool tek_mode_is_unknown;    /* D: tek mode unknown? */
  1234.   bool tek_line_type_is_unknown; /* D: tek line type unknown? */
  1235.   int tek_kermit_fgcolor;    /* D: kermit's foreground color */
  1236.   int tek_kermit_bgcolor;    /* D: kermit's background color */
  1237.   bool tek_position_is_unknown;    /* D: cursor position is unknown? */
  1238.   plIntPoint tek_pos;        /* D: Tektronix cursor position */
  1239.   /* data members specific to ReGIS Plotters */
  1240.   plIntPoint regis_pos;        /* D: ReGIS graphics cursor position */
  1241.   bool regis_position_is_unknown; /* D: graphics cursor position is unknown? */
  1242.   int regis_line_type;        /* D: native ReGIS line type */
  1243.   bool regis_line_type_is_unknown; /* D: ReGIS line type is unknown? */
  1244.   int regis_fgcolor;        /* D: ReGIS foreground color, in range 0..7 */
  1245.   int regis_bgcolor;        /* D: ReGIS background color, in range 0..7 */
  1246.   bool regis_fgcolor_is_unknown; /* D: foreground color unknown? */
  1247.   bool regis_bgcolor_is_unknown; /* D: background color unknown? */
  1248.   /* data members specific to HP-GL (and PCL) Plotters */
  1249.   int hpgl_version;        /* version: 0=HP-GL, 1=HP7550A, 2=HP-GL/2 */
  1250.   int hpgl_rotation;        /* rotation angle (0, 90, 180, or 270) */
  1251.   double hpgl_plot_length;    /* plot length (for HP-GL/2 roll plotters) */
  1252.   plPoint hpgl_p1;        /* scaling point P1 in native HP-GL coors */
  1253.   plPoint hpgl_p2;        /* scaling point P2 in native HP-GL coors */
  1254.   bool hpgl_have_screened_vectors; /* can shade pen marks? (HP-GL/2 only) */
  1255.   bool hpgl_have_char_fill;    /* can shade char interiors? (HP-GL/2 only) */
  1256.   bool hpgl_can_assign_colors;    /* can assign pen colors? (HP-GL/2 only) */
  1257.   bool hpgl_use_opaque_mode;    /* pen marks sh'd be opaque? (HP-GL/2 only) */
  1258.   plColor hpgl_pen_color[HPGL2_MAX_NUM_PENS]; /* D: color array for pens */
  1259.   int hpgl_pen_defined[HPGL2_MAX_NUM_PENS];/*D:0=none,1=soft-defd,2=hard-defd*/
  1260.   int hpgl_pen;            /* D: number of currently selected pen */
  1261.   int hpgl_free_pen;        /* D: pen to be assigned a color next */
  1262.   bool hpgl_bad_pen;        /* D: bad pen (advisory, see h_color.c) */
  1263.   bool hpgl_pendown;        /* D: pen down rather than up? */
  1264.   double hpgl_pen_width;    /* D: pen width(frac of diag dist betw P1,P2)*/
  1265.   int hpgl_line_type;        /* D: line type(HP-GL numbering,solid = -100)*/
  1266.   int hpgl_cap_style;        /* D: cap style for lines (HP-GL/2 numbering)*/
  1267.   int hpgl_join_style;        /* D: join style for lines(HP-GL/2 numbering)*/
  1268.   double hpgl_miter_limit;    /* D: miterlimit for line joins(HP-GL/2 only)*/
  1269.   int hpgl_pen_type;        /* D: sv type (e.g. HPGL_PEN_{SOLID|SHADED}) */
  1270.   double hpgl_pen_option1;    /* D: used for some screened vector types */
  1271.   double hpgl_pen_option2;    /* D: used for some screened vector types */
  1272.   int hpgl_fill_type;        /* D: fill type (one of FILL_SOLID_UNI etc.) */
  1273.   double hpgl_fill_option1;    /* D: used for some fill types */
  1274.   double hpgl_fill_option2;    /* D: used for some fill types */
  1275.   int hpgl_char_rendering_type;    /* D: character rendering type (fill/edge) */
  1276.   int hpgl_symbol_set;        /* D: encoding, 14=ISO-Latin-1 (HP-GL/2 only)*/
  1277.   int hpgl_spacing;        /* D: fontspacing,0=fixed,1=not(HP-GL/2 only)*/
  1278.   int hpgl_posture;        /* D: posture,0=uprite,1=italic(HP-GL/2 only)*/
  1279.   int hpgl_stroke_weight;    /* D: weight,0=normal,3=bold,..(HP-GL/2only)*/
  1280.   int hpgl_pcl_typeface;    /* D: PCL typeface, see g_fontdb.c (HP-GL/2) */
  1281.   int hpgl_charset_lower;    /* D: HP lower-half charset no. (pre-HP-GL/2)*/
  1282.   int hpgl_charset_upper;    /* D: HP upper-half charset no. (pre-HP-GL/2)*/
  1283.   double hpgl_rel_char_height;    /* D: char ht., % of p2y-p1y (HP-GL/2 only) */
  1284.   double hpgl_rel_char_width;    /* D: char width, % of p2x-p1x (HP-GL/2 only)*/
  1285.   double hpgl_rel_label_rise;    /* D: label rise, % of p2y-p1y (HP-GL/2 only)*/
  1286.   double hpgl_rel_label_run;    /* D: label run, % of p2x-p1x (HP-GL/2 only) */
  1287.   double hpgl_tan_char_slant;    /* D: tan of character slant (HP-GL/2 only)*/
  1288.   bool hpgl_position_is_unknown; /* D: HP-GL[/2] cursor position is unknown? */
  1289.   plIntPoint hpgl_pos;        /* D: cursor position (integer HP-GL coors) */
  1290. /* data members specific to Fig Plotters */
  1291.   int fig_drawing_depth;    /* D: fig's curr value for `depth' attribute */
  1292.   int fig_num_usercolors;    /* D: number of colors currently defined */
  1293.   long int fig_usercolors[FIG_MAX_NUM_USER_COLORS]; /* D: colors we've def'd */
  1294.   bool fig_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  1295. /* data members specific to CGM Plotters */
  1296.   int cgm_encoding;        /* CGM_ENCODING_{BINARY,CHARACTER,CLEAR_TEXT}*/
  1297.   int cgm_max_version;        /* upper bound on CGM version number */
  1298.   int cgm_version;        /* D: CGM version for file (1, 2, 3, or 4) */
  1299.   int cgm_profile;        /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1300.   int cgm_need_color;        /* D: non-monochrome? */
  1301.   int cgm_page_version;        /* D: CGM version for current page */
  1302.   int cgm_page_profile;        /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1303.   bool cgm_page_need_color;    /* D: current page is non-monochrome? */
  1304.   plColor cgm_line_color;    /* D: line pen color (24-bit or 48-bit RGB) */
  1305.   plColor cgm_edge_color;    /* D: edge pen color (24-bit or 48-bit RGB) */
  1306.   plColor cgm_fillcolor;    /* D: fill color (24-bit or 48-bit RGB) */
  1307.   plColor cgm_marker_color;    /* D: marker pen color (24-bit or 48-bit RGB)*/
  1308.   plColor cgm_text_color;    /* D: text pen color (24-bit or 48-bit RGB) */
  1309.   plColor cgm_bgcolor;        /* D: background color (24-bit or 48-bit RGB)*/
  1310.   bool cgm_bgcolor_suppressed;    /* D: background color suppressed? */
  1311.   int cgm_line_type;        /* D: one of CGM_L_{SOLID, etc.} */
  1312.   double cgm_dash_offset;    /* D: offset into dash array (`phase') */
  1313.   int cgm_join_style;        /* D: join style for lines (CGM numbering)*/
  1314.   int cgm_cap_style;        /* D: cap style for lines (CGM numbering)*/
  1315.   int cgm_dash_cap_style;    /* D: dash cap style for lines(CGM numbering)*/
  1316.   int cgm_line_width;        /* D: line width in CGM coordinates */
  1317.   int cgm_interior_style;    /* D: one of CGM_INT_STYLE_{EMPTY, etc.} */
  1318.   int cgm_edge_type;        /* D: one of CGM_L_{SOLID, etc.} */
  1319.   double cgm_edge_dash_offset;    /* D: offset into dash array (`phase') */
  1320.   int cgm_edge_join_style;    /* D: join style for edges (CGM numbering)*/
  1321.   int cgm_edge_cap_style;    /* D: cap style for edges (CGM numbering)*/
  1322.   int cgm_edge_dash_cap_style;    /* D: dash cap style for edges(CGM numbering)*/
  1323.   int cgm_edge_width;        /* D: edge width in CGM coordinates */
  1324.   bool cgm_edge_is_visible;    /* D: filled regions have edges? */
  1325.   double cgm_miter_limit;    /* D: CGM's miter limit */
  1326.   int cgm_marker_type;        /* D: one of CGM_M_{DOT, etc.} */
  1327.   int cgm_marker_size;        /* D: marker size in CGM coordinates */
  1328.   int cgm_char_height;        /* D: character height */
  1329.   int cgm_char_base_vector_x;    /* D: character base vector */
  1330.   int cgm_char_base_vector_y;
  1331.   int cgm_char_up_vector_x;    /* D: character up vector */
  1332.   int cgm_char_up_vector_y;
  1333.   int cgm_horizontal_text_alignment; /* D: one of CGM_ALIGN_* */
  1334.   int cgm_vertical_text_alignment; /* D: one of CGM_ALIGN_* */
  1335.   int cgm_font_id;        /* D: PS font in range 0..34 */
  1336.   int cgm_charset_lower;    /* D: lower charset (index into defined list)*/
  1337.   int cgm_charset_upper;    /* D: upper charset (index into defined list)*/
  1338.   int cgm_restricted_text_type;    /* D: one of CGM_RESTRICTED_TEXT_TYPE_* */
  1339. /* data members specific to Illustrator Plotters */
  1340.   int ai_version;        /* AI version 3 or AI version 5? */
  1341.   double ai_pen_cyan;        /* D: pen color (in CMYK space) */
  1342.   double ai_pen_magenta;
  1343.   double ai_pen_yellow;
  1344.   double ai_pen_black;
  1345.   double ai_fill_cyan;        /* D: fill color (in CMYK space) */
  1346.   double ai_fill_magenta;
  1347.   double ai_fill_yellow;
  1348.   double ai_fill_black;
  1349.   bool ai_cyan_used;        /* D: C, M, Y, K have been used? */
  1350.   bool ai_magenta_used;
  1351.   bool ai_yellow_used;
  1352.   bool ai_black_used;
  1353.   int ai_cap_style;        /* D: cap style for lines (PS numbering) */
  1354.   int ai_join_style;        /* D: join style for lines (PS numbering) */
  1355.   double ai_miter_limit;    /* D: miterlimit for line joins */
  1356.   int ai_line_type;        /* D: one of L_* */
  1357.   double ai_line_width;        /* D: line width in printer's points */
  1358.   int ai_fill_rule_type;    /* D: fill rule (FILL_{ODD|NONZERO}_WINDING) */
  1359. /* data members specific to SVG Plotters */
  1360.   double s_matrix[6];        /* D: default transformation matrix for page */
  1361.   bool s_matrix_is_unknown;    /* D: matrix has not yet been set? */
  1362.   bool s_matrix_is_bogus;    /* D: matrix has been set, but is bogus? */
  1363.   plColor s_bgcolor;        /* D: background color (RGB) */
  1364.   bool s_bgcolor_suppressed;    /* D: background color suppressed? */
  1365. /* data members specific to PNM Plotters (derived from Bitmap Plotters) */
  1366.   bool n_portable_output;    /* portable, not binary output format? */
  1367. #ifdef INCLUDE_PNG_SUPPORT
  1368. /* data members specific to PNG Plotters (derived from Bitmap Plotters) */
  1369.   bool z_interlace;        /* interlaced PNG? */
  1370.   bool z_transparent;        /* transparent PNG? */
  1371.   plColor z_transparent_color;    /* if so, transparent color (24-bit RGB) */
  1372. #endif /* INCLUDE_PNG_SUPPORT */
  1373. /* data members specific to GIF Plotters */
  1374.   int i_xn, i_yn;        /* bitmap dimensions */
  1375.   int i_num_pixels;        /* total pixels (used by scanner) */
  1376.   bool i_animation;        /* animated (multi-image) GIF? */
  1377.   int i_iterations;        /* number of times GIF should be looped */
  1378.   int i_delay;            /* delay after image, in 1/100 sec units */
  1379.   bool i_interlace;        /* interlaced GIF? */
  1380.   bool i_transparent;        /* transparent GIF? */
  1381.   plColor i_transparent_color;    /* if so, transparent color (24-bit RGB) */
  1382.   voidptr_t i_arc_cache_data;    /* pointer to cache (used by miPolyArc_r) */
  1383.   int i_transparent_index;    /* D: transparent color index (if any) */
  1384.   voidptr_t i_painted_set;    /* D: libxmi's canvas (a (miPaintedSet *)) */
  1385.   voidptr_t i_canvas;        /* D: libxmi's canvas (a (miCanvas *)) */
  1386.   plColor i_colormap[256];    /* D: frame colormap (containing 24-bit RGBs)*/
  1387.   int i_num_color_indices;    /* D: number of color indices allocated */
  1388.   bool i_frame_nonempty;    /* D: something drawn in current frame? */
  1389.   int i_bit_depth;        /* D: bit depth (ceil(log2(num_indices))) */
  1390.   int i_pixels_scanned;        /* D: number that scanner has scanned */
  1391.   int i_pass;            /* D: scanner pass (used if interlacing) */
  1392.   plIntPoint i_hot;        /* D: scanner hot spot */
  1393.   plColor i_global_colormap[256]; /* D: colormap for first frame (stashed) */
  1394.   int i_num_global_color_indices;/* D: number of indices in global colormap */
  1395.   bool i_header_written;    /* D: GIF header written yet? */
  1396. #ifndef X_DISPLAY_MISSING
  1397. /* data members specific to X Drawable Plotters and X Plotters */
  1398.   Display *x_dpy;        /* X display */
  1399.   Visual *x_visual;        /* X visual */
  1400.   Drawable x_drawable1;        /* an X drawable (e.g. a pixmap) */
  1401.   Drawable x_drawable2;        /* an X drawable (e.g. a window) */
  1402.   Drawable x_drawable3;        /* graphics buffer, if double buffering */
  1403.   int x_double_buffering;    /* double buffering type (if any) */
  1404.   long int x_max_polyline_len;    /* limit on polyline len (X display-specific)*/
  1405.   plFontRecord *x_fontlist;    /* D: head of list of retrieved X fonts */
  1406.   plColorRecord *x_colorlist;    /* D: head of list of retrieved X color cells*/
  1407.   Colormap x_cmap;        /* D: colormap */
  1408.   int x_cmap_type;        /* D: colormap type (orig./copied/bad) */
  1409.   bool x_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  1410.   bool x_bg_color_warning_issued; /* D: issued warning on bg color */
  1411.   int x_paint_pixel_count;    /* D: times point() is invoked to set a pixel*/
  1412. /* additional data members specific to X Plotters */
  1413.   XtAppContext y_app_con;    /* application context */
  1414.   Widget y_toplevel;        /* toplevel widget */
  1415.   Widget y_canvas;        /* Label widget */
  1416.   Drawable y_drawable4;        /* used for server-side double buffering */
  1417.   bool y_auto_flush;        /* do an XFlush() after each drawing op? */
  1418.   bool y_vanish_on_delete;    /* window(s) disappear on Plotter deletion? */
  1419.   pid_t *y_pids;        /* D: list of pids of forked-off processes */
  1420.   int y_num_pids;        /* D: number of pids in list */
  1421.   int y_event_handler_count;    /* D: times that event handler is invoked */
  1422. #endif /* not X_DISPLAY_MISSING */
  1423. #endif /* NOT_LIBPLOTTER */
  1424.  
  1425. #ifndef NOT_LIBPLOTTER
  1426.   /* STATIC DATA MEMBERS, protected, which are defined in g_defplot.c.  (In
  1427.      libplot, these variables are globals, rather than static members of
  1428.      the Plotter class.  That's arranged by #ifdef's in libplot/extern.h.)  */
  1429.  
  1430.   /* These maintain a sparse array of pointers to Plotter instances. */
  1431.   static Plotter **_plotters;    /* D: sparse array of Plotter instances */
  1432.   static int _plotters_len;    /* D: length of sparse array */
  1433.  
  1434.   /* This stores the global Plotter parameters used by the old,
  1435.      non-thread-safe C++ binding (the user specifies them with
  1436.      Plotter::parampl). */
  1437.   static PlotterParams *_old_api_global_plotter_params;
  1438. #endif /* not NOT_LIBPLOTTER */
  1439.  
  1440.   /* PLOTTER PROTECTED FUNCTIONS.  In libplotter they're declared here, as
  1441.      protected members of the base Plotter class.  (In libplot they're
  1442.      declared in libplot/extern.h.)  Since they're protected, derived
  1443.      classes can access them, i.e. call them.  */
  1444.  
  1445. #ifndef NOT_LIBPLOTTER
  1446.   void _flush_plotter_outstreams (void);
  1447. #endif /* NOT_LIBPLOTTER */
  1448.  
  1449. }
  1450. #ifdef NOT_LIBPLOTTER
  1451. Plotter;
  1452. #else  /* not NOT_LIBPLOTTER */
  1453. ;
  1454. #endif /* not NOT_LIBPLOTTER */
  1455.  
  1456. #undef P___
  1457. #undef Q___
  1458.  
  1459.  
  1460. #ifndef NOT_LIBPLOTTER
  1461. /****************** DERIVED CLASSES (libplotter only) ********************/
  1462.  
  1463. /* The derived Plotter classes extensively override the generic Plotter
  1464.    methods; the non-private ones, at least.  Note that in libplot, this
  1465.    overriding is accomplished differently: `derived' Plotter structs are
  1466.    initialized to contain function pointers that may point to the
  1467.    non-generic methods.  The files ?_defplot.c contain the structures
  1468.    which, in libplot, are used to initialize the function-pointer part of
  1469.    the derived Plotter structs.
  1470.  
  1471.    The device-specific data members which, in libplot, all appear in every
  1472.    Plotter struct, are in libplotter spread among the derived Plotter
  1473.    classes, as they logically should be.  */
  1474.  
  1475. /* The MetaPlotter class, which produces GNU metafile output */
  1476. class MetaPlotter : public Plotter
  1477. {
  1478.  private:
  1479.   /* disallow copying and assignment */
  1480.   MetaPlotter (const MetaPlotter& oldplotter);  
  1481.   MetaPlotter& operator= (const MetaPlotter& oldplotter);
  1482.  public:
  1483.   /* ctors (old-style, not thread-safe) */
  1484.   MetaPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1485.   MetaPlotter (FILE *outfile);
  1486.   MetaPlotter (istream& in, ostream& out, ostream& err);
  1487.   MetaPlotter (ostream& out);
  1488.   MetaPlotter ();
  1489.   /* ctors (new-style, thread-safe) */
  1490.   MetaPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1491.   MetaPlotter (FILE *outfile, PlotterParams ¶ms);
  1492.   MetaPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1493.   MetaPlotter (ostream& out, PlotterParams ¶ms);
  1494.   MetaPlotter (PlotterParams ¶ms);
  1495.   /* dtor */
  1496.   virtual ~MetaPlotter ();
  1497.  protected:
  1498.   /* protected methods (overriding Plotter methods) */
  1499.   bool begin_page (void);
  1500.   bool end_page (void);
  1501.   bool erase_page (void);
  1502.   bool paint_marker (int type, double size);
  1503.   bool paint_paths (void);
  1504.   bool path_is_flushable (void);
  1505.   void paint_text_string_with_escapes (const unsigned char *s, int h_just, int v_just);
  1506.   void initialize (void);
  1507.   void maybe_prepaint_segments (int prev_num_segments);
  1508.   void paint_path (void);
  1509.   void paint_point (void);
  1510.   void terminate (void);
  1511.   /* MetaPlotter-specific internal functions */
  1512.   void _m_emit_integer (int x);
  1513.   void _m_emit_float (double x);  
  1514.   void _m_emit_op_code (int c);  
  1515.   void _m_emit_string (const char *s);  
  1516.   void _m_emit_terminator (void);
  1517.   void _m_paint_path_internal (const plPath *path);
  1518.   void _m_set_attributes (unsigned int mask);
  1519.   /* MetaPlotter-specific data members */
  1520.   /* 0. parameters */
  1521.   bool meta_portable_output;    /* portable, not binary output format? */
  1522.   /* 1. dynamic attributes, general */
  1523.   plPoint meta_pos;        /* graphics cursor position */
  1524.   bool meta_position_is_unknown; /* position is unknown? */
  1525.   double meta_m_user_to_ndc[6];    /* user->NDC transformation matrix */
  1526.   /* 2. dynamic attributes, path-related */
  1527.   int meta_fill_rule_type;    /* one of FILL_*, determined by fill rule */
  1528.   int meta_line_type;        /* one of L_*, determined by line mode */
  1529.   bool meta_points_are_connected; /* if not set, path displayed as points */
  1530.   int meta_cap_type;        /* one of CAP_*, determined by cap mode */
  1531.   int meta_join_type;        /* one of JOIN_*, determined by join mode */
  1532.   double meta_miter_limit;    /* miter limit for line joins */
  1533.   double meta_line_width;    /* width of lines in user coordinates */
  1534.   bool meta_line_width_is_default; /* line width is default value? */
  1535.   const double *meta_dash_array; /* array of dash on/off lengths(nonnegative)*/
  1536.   int meta_dash_array_len;    /* length of same */
  1537.   double meta_dash_offset;    /* offset distance into dash array (`phase') */
  1538.   bool meta_dash_array_in_effect; /* dash array should override line mode? */
  1539.   int meta_pen_type;        /* pen type (0 = no pen, 1 = pen) */
  1540.   int meta_fill_type;        /* fill type (0 = no fill, 1 = fill, ...) */
  1541.   int meta_orientation;            /* orientation of circles etc.(1=c'clockwise)*/
  1542.   /* 3. dynamic attributes, text-related */
  1543.   const char *meta_font_name;    /* font name */
  1544.   double meta_font_size;    /* font size in user coordinates */
  1545.   bool meta_font_size_is_default; /* font size is Plotter default? */
  1546.   double meta_text_rotation;    /* degrees counterclockwise, for labels */
  1547.   /* 4. dynamic color attributes (fgcolor and fillcolor are path-related;
  1548.      fgcolor affects other primitives too) */
  1549.   plColor meta_fgcolor;        /* foreground color, i.e., pen color */
  1550.   plColor meta_fillcolor_base;    /* fill color */
  1551.   plColor meta_bgcolor;        /* background color for graphics display */
  1552. };
  1553.  
  1554. /* The BitmapPlotter class, from which PNMPlotter and PNGPlotter are derived */
  1555. class BitmapPlotter : public Plotter
  1556. {
  1557.  private:
  1558.   /* disallow copying and assignment */
  1559.   BitmapPlotter (const BitmapPlotter& oldplotter);  
  1560.   BitmapPlotter& operator= (const BitmapPlotter& oldplotter);
  1561.  public:
  1562.   /* ctors (old-style, not thread-safe) */
  1563.   BitmapPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1564.   BitmapPlotter (FILE *outfile);
  1565.   BitmapPlotter (istream& in, ostream& out, ostream& err);
  1566.   BitmapPlotter (ostream& out);
  1567.   BitmapPlotter ();
  1568.   /* ctors (new-style, thread-safe) */
  1569.   BitmapPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1570.   BitmapPlotter (FILE *outfile, PlotterParams ¶ms);
  1571.   BitmapPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1572.   BitmapPlotter (ostream& out, PlotterParams ¶ms);
  1573.   BitmapPlotter (PlotterParams ¶ms);
  1574.   /* dtor */
  1575.   virtual ~BitmapPlotter ();
  1576.  protected:
  1577.   /* protected methods (overriding Plotter methods) */
  1578.   bool begin_page (void);
  1579.   bool erase_page (void);
  1580.   bool end_page (void);
  1581.   void paint_point (void);
  1582.   void initialize (void);
  1583.   void terminate (void);
  1584.   void paint_path (void);
  1585.   bool paint_paths (void);
  1586.   /* internal functions that are overridden in derived classes (crocks) */
  1587.   virtual int _maybe_output_image (void);
  1588.   /* BitmapPlotter-specific internal functions */
  1589.   void _b_delete_image (void);
  1590.   void _b_draw_elliptic_arc (plPoint p0, plPoint p1, plPoint pc);
  1591.   void _b_draw_elliptic_arc_2 (plPoint p0, plPoint p1, plPoint pc);
  1592.   void _b_draw_elliptic_arc_internal (int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange);
  1593.   void _b_new_image (void);
  1594.   /* BitmapPlotter-specific data members */
  1595.   voidptr_t b_arc_cache_data;    /* pointer to cache (used by miPolyArc_r) */
  1596.   int b_xn, b_yn;        /* bitmap dimensions */
  1597.   voidptr_t b_painted_set;    /* D: libxmi's canvas (a (miPaintedSet *)) */
  1598.   voidptr_t b_canvas;        /* D: libxmi's canvas (a (miCanvas *)) */
  1599. };
  1600.  
  1601. /* The TekPlotter class, which produces Tektronix output */
  1602. class TekPlotter : public Plotter
  1603. {
  1604.  private:
  1605.   /* disallow copying and assignment */
  1606.   TekPlotter (const TekPlotter& oldplotter);  
  1607.   TekPlotter& operator= (const TekPlotter& oldplotter);
  1608.  public:
  1609.   /* ctors (old-style, not thread-safe) */
  1610.   TekPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1611.   TekPlotter (FILE *outfile);
  1612.   TekPlotter (istream& in, ostream& out, ostream& err);
  1613.   TekPlotter (ostream& out);
  1614.   TekPlotter ();
  1615.   /* ctors (new-style, thread-safe) */
  1616.   TekPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1617.   TekPlotter (FILE *outfile, PlotterParams ¶ms);
  1618.   TekPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1619.   TekPlotter (ostream& out, PlotterParams ¶ms);
  1620.   TekPlotter (PlotterParams ¶ms);
  1621.   /* dtor */
  1622.   virtual ~TekPlotter ();
  1623.  protected:
  1624.   /* protected methods (overriding Plotter methods) */
  1625.   bool begin_page (void);
  1626.   bool erase_page (void);
  1627.   bool end_page (void);
  1628.   bool path_is_flushable (void);
  1629.   void paint_point (void);
  1630.   void initialize (void);
  1631.   void terminate (void);
  1632.   void maybe_prepaint_segments (int prev_num_segments);
  1633.   /* TekPlotter-specific internal functions */
  1634.   void _t_set_attributes (void);
  1635.   void _t_set_bg_color (void);
  1636.   void _t_set_pen_color (void);
  1637.   void _tek_mode (int newmode);
  1638.   void _tek_move (int xx, int yy);
  1639.   void _tek_vector (int xx, int yy);
  1640.   void _tek_vector_compressed (int xx, int yy, int oldxx, int oldyy, bool force);
  1641.   /* TekPlotter-specific data members */
  1642.   int tek_display_type;        /* which sort of Tektronix? */
  1643.   int tek_mode;            /* D: one of MODE_* */
  1644.   int tek_line_type;        /* D: one of L_* */
  1645.   bool tek_mode_is_unknown;    /* D: tek mode unknown? */
  1646.   bool tek_line_type_is_unknown; /* D: tek line type unknown? */
  1647.   int tek_kermit_fgcolor;    /* D: kermit's foreground color */
  1648.   int tek_kermit_bgcolor;    /* D: kermit's background color */
  1649.   bool tek_position_is_unknown;    /* D: cursor position is unknown? */
  1650.   plIntPoint tek_pos;        /* D: Tektronix cursor position */
  1651. };
  1652.  
  1653. /* The ReGISPlotter class, which produces ReGIS output */
  1654. class ReGISPlotter : public Plotter
  1655. {
  1656.  private:
  1657.   /* disallow copying and assignment */
  1658.   ReGISPlotter (const ReGISPlotter& oldplotter);  
  1659.   ReGISPlotter& operator= (const ReGISPlotter& oldplotter);
  1660.  public:
  1661.   /* ctors (old-style, not thread-safe) */
  1662.   ReGISPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1663.   ReGISPlotter (FILE *outfile);
  1664.   ReGISPlotter (istream& in, ostream& out, ostream& err);
  1665.   ReGISPlotter (ostream& out);
  1666.   ReGISPlotter ();
  1667.   /* ctors (new-style, thread-safe) */
  1668.   ReGISPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1669.   ReGISPlotter (FILE *outfile, PlotterParams ¶ms);
  1670.   ReGISPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1671.   ReGISPlotter (ostream& out, PlotterParams ¶ms);
  1672.   ReGISPlotter (PlotterParams ¶ms);
  1673.   /* dtor */
  1674.   virtual ~ReGISPlotter ();
  1675.  protected:
  1676.   /* protected methods (overriding Plotter methods) */
  1677.   bool begin_page (void);
  1678.   bool erase_page (void);
  1679.   bool end_page (void);
  1680.   void paint_point (void);
  1681.   bool path_is_flushable (void);
  1682.   void initialize (void);
  1683.   void terminate (void);
  1684.   void maybe_prepaint_segments (int prev_num_segments);
  1685.   void paint_path (void);
  1686.   bool paint_paths (void);
  1687.   /* ReGISPlotter-specific internal functions */
  1688.   void _r_set_attributes (void);
  1689.   void _r_set_bg_color (void);
  1690.   void _r_set_fill_color (void);
  1691.   void _r_set_pen_color (void);
  1692.   void _regis_move (int xx, int yy);
  1693.   /* ReGISPlotter-specific data members */
  1694.   plIntPoint regis_pos;        /* D: ReGIS graphics cursor position */
  1695.   bool regis_position_is_unknown; /* D: graphics cursor position is unknown? */
  1696.   int regis_line_type;        /* D: native ReGIS line type */
  1697.   bool regis_line_type_is_unknown; /* D: ReGIS line type is unknown? */
  1698.   int regis_fgcolor;        /* D: ReGIS foreground color, in range 0..7 */
  1699.   int regis_bgcolor;        /* D: ReGIS background color, in range 0..7 */
  1700.   bool regis_fgcolor_is_unknown; /* D: foreground color unknown? */
  1701.   bool regis_bgcolor_is_unknown; /* D: background color unknown? */
  1702. };
  1703.  
  1704. /* The HPGLPlotter class, which produces HP-GL or HP-GL/2 output */
  1705. class HPGLPlotter : public Plotter
  1706. {
  1707.  private:
  1708.   /* disallow copying and assignment */
  1709.   HPGLPlotter (const HPGLPlotter& oldplotter);  
  1710.   HPGLPlotter& operator= (const HPGLPlotter& oldplotter);
  1711.  public:
  1712.   /* ctors (old-style, not thread-safe) */
  1713.   HPGLPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1714.   HPGLPlotter (FILE *outfile);
  1715.   HPGLPlotter (istream& in, ostream& out, ostream& err);
  1716.   HPGLPlotter (ostream& out);
  1717.   HPGLPlotter ();
  1718.   /* ctors (new-style, thread-safe) */
  1719.   HPGLPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1720.   HPGLPlotter (FILE *outfile, PlotterParams ¶ms);
  1721.   HPGLPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1722.   HPGLPlotter (ostream& out, PlotterParams ¶ms);
  1723.   HPGLPlotter (PlotterParams ¶ms);
  1724.   /* dtor */
  1725.   virtual ~HPGLPlotter ();
  1726.  protected:
  1727.   /* protected methods (overriding Plotter methods, overridden in
  1728.      PCLPlotter class */
  1729.   void initialize (void);
  1730.   void terminate (void);
  1731.   /* protected methods (overriding Plotter methods) */
  1732.   bool begin_page (void);
  1733.   bool erase_page (void);
  1734.   bool end_page (void);
  1735.   void paint_point (void);
  1736.   void paint_path (void);
  1737.   bool paint_paths (void);
  1738.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1739.   /* internal functions that are overridden in the PCLPlotter class */
  1740.   virtual void _maybe_switch_to_hpgl (void);
  1741.   virtual void _maybe_switch_from_hpgl (void);
  1742.   /* other HPGLPlotter-specific internal functions */
  1743.   bool _hpgl2_maybe_update_font (void);
  1744.   bool _hpgl_maybe_update_font (void);
  1745.   bool _parse_pen_string (const char *pen_s);
  1746.   int _hpgl_pseudocolor (int red, int green, int blue, bool restrict_white);
  1747.   void _h_set_attributes (void);
  1748.   void _h_set_fill_color (bool force_pen_color);
  1749.   void _h_set_font (void);
  1750.   void _h_set_pen_color (int hpgl_object_type);
  1751.   void _h_set_position (void);
  1752.   void _hpgl_shaded_pseudocolor (int red, int green, int blue, int *pen, double *shading);
  1753.   void _set_hpgl_fill_type (int fill_type, double option1, double option2);
  1754.   void _set_hpgl_pen_type (int pen_type, double option1, double option2);
  1755.   void _set_hpgl_pen (int pen);
  1756.   /* HPGLPlotter-specific data members */
  1757.   int hpgl_version;        /* version: 0=HP-GL, 1=HP7550A, 2=HP-GL/2 */
  1758.   int hpgl_rotation;        /* rotation angle (0, 90, 180, or 270) */
  1759.   double hpgl_plot_length;    /* plot length (for HP-GL/2 roll plotters) */
  1760.   plPoint hpgl_p1;        /* scaling point P1 in native HP-GL coors */
  1761.   plPoint hpgl_p2;        /* scaling point P2 in native HP-GL coors */
  1762.   bool hpgl_have_screened_vectors; /* can shade pen marks? (HP-GL/2 only) */
  1763.   bool hpgl_have_char_fill;    /* can shade char interiors? (HP-GL/2 only) */
  1764.   bool hpgl_can_assign_colors;    /* can assign pen colors? (HP-GL/2 only) */
  1765.   bool hpgl_use_opaque_mode;    /* pen marks sh'd be opaque? (HP-GL/2 only) */
  1766.   plColor hpgl_pen_color[HPGL2_MAX_NUM_PENS]; /* D: color array for pens */
  1767.   int hpgl_pen_defined[HPGL2_MAX_NUM_PENS];/*D:0=none,1=soft-defd,2=hard-defd*/
  1768.   int hpgl_pen;            /* D: number of currently selected pen */
  1769.   int hpgl_free_pen;        /* D: pen to be assigned a color next */
  1770.   bool hpgl_bad_pen;        /* D: bad pen (advisory, see h_color.c) */
  1771.   bool hpgl_pendown;        /* D: pen down rather than up? */
  1772.   double hpgl_pen_width;    /* D: pen width(frac of diag dist betw P1,P2)*/
  1773.   int hpgl_line_type;        /* D: line type(HP-GL numbering,solid = -100)*/
  1774.   int hpgl_cap_style;        /* D: cap style for lines (HP-GL/2 numbering)*/
  1775.   int hpgl_join_style;        /* D: join style for lines(HP-GL/2 numbering)*/
  1776.   double hpgl_miter_limit;    /* D: miterlimit for line joins(HP-GL/2 only)*/
  1777.   int hpgl_pen_type;        /* D: sv type (e.g. HPGL_PEN_{SOLID|SHADED}) */
  1778.   double hpgl_pen_option1;    /* D: used for some screened vector types */
  1779.   double hpgl_pen_option2;    /* D: used for some screened vector types */
  1780.   int hpgl_fill_type;        /* D: fill type (one of FILL_SOLID_UNI etc.) */
  1781.   double hpgl_fill_option1;    /* D: used for some fill types */
  1782.   double hpgl_fill_option2;    /* D: used for some fill types */
  1783.   int hpgl_char_rendering_type;    /* D: character rendering type (fill/edge) */
  1784.   int hpgl_symbol_set;        /* D: encoding, 14=ISO-Latin-1 (HP-GL/2 only)*/
  1785.   int hpgl_spacing;        /* D: fontspacing,0=fixed,1=not(HP-GL/2 only)*/
  1786.   int hpgl_posture;        /* D: posture,0=uprite,1=italic(HP-GL/2 only)*/
  1787.   int hpgl_stroke_weight;    /* D: weight,0=normal,3=bold,..(HP-GL/2only)*/
  1788.   int hpgl_pcl_typeface;    /* D: typeface, see g_fontdb.c (HP-GL/2) */
  1789.   int hpgl_charset_lower;    /* D: HP lower-half charset no. (pre-HP-GL/2)*/
  1790.   int hpgl_charset_upper;    /* D: HP upper-half charset no. (pre-HP-GL/2)*/
  1791.   double hpgl_rel_char_height;    /* D: char ht., % of p2y-p1y (HP-GL/2 only) */
  1792.   double hpgl_rel_char_width;    /* D: char width, % of p2x-p1x (HP-GL/2 only)*/
  1793.   double hpgl_rel_label_rise;    /* D: label rise, % of p2y-p1y (HP-GL/2 only)*/
  1794.   double hpgl_rel_label_run;    /* D: label run, % of p2x-p1x (HP-GL/2 only) */
  1795.   double hpgl_tan_char_slant;    /* D: tan of character slant (HP-GL/2 only)*/
  1796.   bool hpgl_position_is_unknown; /* D: HP-GL[/2] cursor position is unknown? */
  1797.   plIntPoint hpgl_pos;        /* D: cursor position (integer HP-GL coors) */
  1798. };
  1799.  
  1800. /* The PCLPlotter class, which produces PCL 5 output */
  1801. class PCLPlotter : public HPGLPlotter
  1802. {
  1803.  private:
  1804.   /* disallow copying and assignment */
  1805.   PCLPlotter (const PCLPlotter& oldplotter);  
  1806.   PCLPlotter& operator= (const PCLPlotter& oldplotter);
  1807.  public:
  1808.   /* ctors (old-style, not thread-safe) */
  1809.   PCLPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1810.   PCLPlotter (FILE *outfile);
  1811.   PCLPlotter (istream& in, ostream& out, ostream& err);
  1812.   PCLPlotter (ostream& out);
  1813.   PCLPlotter ();
  1814.   /* ctors (new-style, thread-safe) */
  1815.   PCLPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1816.   PCLPlotter (FILE *outfile, PlotterParams ¶ms);
  1817.   PCLPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1818.   PCLPlotter (ostream& out, PlotterParams ¶ms);
  1819.   PCLPlotter (PlotterParams ¶ms);
  1820.   /* dtor */
  1821.   virtual ~PCLPlotter ();
  1822.  protected:
  1823.   /* protected methods (overriding HPGLPlotter methods) */
  1824.   void initialize (void);
  1825.   void terminate (void);
  1826.   /* internal functions that override HPGLPlotter internal functions */
  1827.   void _maybe_switch_to_hpgl (void);
  1828.   void _maybe_switch_from_hpgl (void);
  1829. };
  1830.  
  1831. /* The FigPlotter class, which produces Fig-format output for xfig */
  1832. class FigPlotter : public Plotter
  1833. {
  1834.  private:
  1835.   /* disallow copying and assignment */
  1836.   FigPlotter (const FigPlotter& oldplotter);  
  1837.   FigPlotter& operator= (const FigPlotter& oldplotter);
  1838.  public:
  1839.   /* ctors (old-style, not thread-safe) */
  1840.   FigPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1841.   FigPlotter (FILE *outfile);
  1842.   FigPlotter (istream& in, ostream& out, ostream& err);
  1843.   FigPlotter (ostream& out);
  1844.   FigPlotter ();
  1845.   /* ctors (new-style, thread-safe) */
  1846.   FigPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1847.   FigPlotter (FILE *outfile, PlotterParams ¶ms);
  1848.   FigPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1849.   FigPlotter (ostream& out, PlotterParams ¶ms);
  1850.   FigPlotter (PlotterParams ¶ms);
  1851.   /* dtor */
  1852.   virtual ~FigPlotter ();
  1853.  protected:
  1854.   /* protected methods (overriding Plotter methods) */
  1855.   bool begin_page (void);
  1856.   bool erase_page (void);
  1857.   bool end_page (void);
  1858.   void paint_point (void);
  1859.   void initialize (void);
  1860.   void terminate (void);
  1861.   void paint_path (void);
  1862.   bool paint_paths (void);
  1863.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1864.   bool retrieve_font (void);
  1865.   /* FigPlotter-specific internal functions */
  1866.   int _fig_color (int red, int green, int blue);
  1867.   void _f_compute_line_style (int *style, double *spacing);
  1868.   void _f_draw_arc_internal (double xc, double yc, double x0, double y0, double x1, double y1);
  1869.   void _f_draw_box_internal (plPoint p0, plPoint p1);
  1870.   void _f_draw_ellipse_internal (double x, double y, double rx, double ry, double angle, int subtype);
  1871.   void _f_set_fill_color (void);
  1872.   void _f_set_pen_color (void);
  1873.   /* FigPlotter-specific data members */
  1874.   int fig_drawing_depth;    /* D: fig's curr value for `depth' attribute */
  1875.   int fig_num_usercolors;    /* D: number of colors currently defined */
  1876.   long int fig_usercolors[FIG_MAX_NUM_USER_COLORS]; /* D: colors we've def'd */
  1877.   bool fig_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  1878. };
  1879.  
  1880. /* The CGMPlotter class, which produces CGM (Computer Graphics Metafile)
  1881.    output */
  1882. class CGMPlotter : public Plotter
  1883. {
  1884.  private:
  1885.   /* disallow copying and assignment */
  1886.   CGMPlotter (const CGMPlotter& oldplotter);  
  1887.   CGMPlotter& operator= (const CGMPlotter& oldplotter);
  1888.  public:
  1889.   /* ctors (old-style, not thread-safe) */
  1890.   CGMPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1891.   CGMPlotter (FILE *outfile);
  1892.   CGMPlotter (istream& in, ostream& out, ostream& err);
  1893.   CGMPlotter (ostream& out);
  1894.   CGMPlotter ();
  1895.   /* ctors (new-style, thread-safe) */
  1896.   CGMPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1897.   CGMPlotter (FILE *outfile, PlotterParams ¶ms);
  1898.   CGMPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1899.   CGMPlotter (ostream& out, PlotterParams ¶ms);
  1900.   CGMPlotter (PlotterParams ¶ms);
  1901.   /* dtor */
  1902.   virtual ~CGMPlotter ();
  1903.  protected:
  1904.   /* protected methods (overriding Plotter methods) */
  1905.   bool begin_page (void);
  1906.   bool erase_page (void);
  1907.   bool end_page (void);
  1908.   void paint_point (void);
  1909.   void initialize (void);
  1910.   void terminate (void);
  1911.   void paint_path (void);
  1912.   bool paint_marker (int type, double size);
  1913.   bool paint_paths (void);
  1914.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1915.   /* internal functions */
  1916.   void _c_set_attributes (int cgm_object_type);
  1917.   void _c_set_bg_color (void);
  1918.   void _c_set_fill_color (int cgm_object_type);
  1919.   void _c_set_pen_color (int cgm_object_type);
  1920.   /* CGMPlotter-specific data members */
  1921.   int cgm_encoding;        /* CGM_ENCODING_{BINARY,CHARACTER,CLEAR_TEXT}*/
  1922.   int cgm_max_version;        /* upper bound on CGM version number */
  1923.   int cgm_version;        /* D: CGM version for file (1, 2, 3, or 4) */
  1924.   int cgm_profile;        /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1925.   int cgm_need_color;        /* D: non-monochrome? */
  1926.   int cgm_page_version;        /* D: CGM version for current page */
  1927.   int cgm_page_profile;        /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1928.   bool cgm_page_need_color;    /* D: current page is non-monochrome? */
  1929.   plColor cgm_line_color;    /* D: line pen color (24-bit or 48-bit RGB) */
  1930.   plColor cgm_edge_color;    /* D: edge pen color (24-bit or 48-bit RGB) */
  1931.   plColor cgm_fillcolor;    /* D: fill color (24-bit or 48-bit RGB) */
  1932.   plColor cgm_marker_color;    /* D: marker pen color (24-bit or 48-bit RGB)*/
  1933.   plColor cgm_text_color;    /* D: text pen color (24-bit or 48-bit RGB) */
  1934.   plColor cgm_bgcolor;        /* D: background color (24-bit or 48-bit RGB)*/
  1935.   bool cgm_bgcolor_suppressed;    /* D: background color suppressed? */
  1936.   int cgm_line_type;        /* D: one of CGM_L_{SOLID, etc.} */
  1937.   double cgm_dash_offset;    /* D: offset into dash array (`phase') */
  1938.   int cgm_join_style;        /* D: join style for lines (CGM numbering)*/
  1939.   int cgm_cap_style;        /* D: cap style for lines (CGM numbering)*/
  1940.   int cgm_dash_cap_style;    /* D: dash cap style for lines(CGM numbering)*/
  1941.   int cgm_line_width;        /* D: line width in CGM coordinates */
  1942.   int cgm_interior_style;    /* D: one of CGM_INT_STYLE_{EMPTY, etc.} */
  1943.   int cgm_edge_type;        /* D: one of CGM_L_{SOLID, etc.} */
  1944.   double cgm_edge_dash_offset;    /* D: offset into dash array (`phase') */
  1945.   int cgm_edge_join_style;    /* D: join style for edges (CGM numbering)*/
  1946.   int cgm_edge_cap_style;    /* D: cap style for edges (CGM numbering)*/
  1947.   int cgm_edge_dash_cap_style;    /* D: dash cap style for edges(CGM numbering)*/
  1948.   int cgm_edge_width;        /* D: edge width in CGM coordinates */
  1949.   bool cgm_edge_is_visible;    /* D: filled regions have edges? */
  1950.   double cgm_miter_limit;    /* D: CGM's miter limit */
  1951.   int cgm_marker_type;        /* D: one of CGM_M_{DOT, etc.} */
  1952.   int cgm_marker_size;        /* D: marker size in CGM coordinates */
  1953.   int cgm_char_height;        /* D: character height */
  1954.   int cgm_char_base_vector_x;    /* D: character base vector */
  1955.   int cgm_char_base_vector_y;
  1956.   int cgm_char_up_vector_x;    /* D: character up vector */
  1957.   int cgm_char_up_vector_y;
  1958.   int cgm_horizontal_text_alignment; /* D: one of CGM_ALIGN_* */
  1959.   int cgm_vertical_text_alignment; /* D: one of CGM_ALIGN_* */
  1960.   int cgm_font_id;        /* D: PS font in range 0..34 */
  1961.   int cgm_charset_lower;    /* D: lower charset (index into defined list)*/
  1962.   int cgm_charset_upper;    /* D: upper charset (index into defined list)*/
  1963.   int cgm_restricted_text_type;    /* D: one of CGM_RESTRICTED_TEXT_TYPE_* */
  1964. };
  1965.  
  1966. /* The PSPlotter class, which produces idraw-editable PS output */
  1967. class PSPlotter : public Plotter
  1968. {
  1969.  private:
  1970.   /* disallow copying and assignment */
  1971.   PSPlotter (const PSPlotter& oldplotter);  
  1972.   PSPlotter& operator= (const PSPlotter& oldplotter);
  1973.  public:
  1974.   /* ctors (old-style, not thread-safe) */
  1975.   PSPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1976.   PSPlotter (FILE *outfile);
  1977.   PSPlotter (istream& in, ostream& out, ostream& err);
  1978.   PSPlotter (ostream& out);
  1979.   PSPlotter ();
  1980.   /* ctors (new-style, thread-safe) */
  1981.   PSPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  1982.   PSPlotter (FILE *outfile, PlotterParams ¶ms);
  1983.   PSPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  1984.   PSPlotter (ostream& out, PlotterParams ¶ms);
  1985.   PSPlotter (PlotterParams ¶ms);
  1986.   /* dtor */
  1987.   virtual ~PSPlotter ();
  1988.  protected:
  1989.   /* protected methods (overriding Plotter methods) */
  1990.   bool begin_page (void);
  1991.   bool erase_page (void);
  1992.   bool end_page (void);
  1993.   void paint_point (void);
  1994.   void initialize (void);
  1995.   void terminate (void);
  1996.   void paint_path (void);
  1997.   bool paint_paths (void);
  1998.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1999.   /* PSPlotter-specific internal functions */
  2000.   double _p_emit_common_attributes (void);
  2001.   void _p_compute_idraw_bgcolor (void);
  2002.   void _p_fellipse_internal (double x, double y, double rx, double ry, double angle, bool circlep);
  2003.   void _p_set_fill_color (void);
  2004.   void _p_set_pen_color (void);
  2005. };
  2006.  
  2007. /* The AIPlotter class, which produces output editable by Adobe Illustrator */
  2008. class AIPlotter : public Plotter
  2009. {
  2010.  private:
  2011.   /* disallow copying and assignment */
  2012.   AIPlotter (const AIPlotter& oldplotter);  
  2013.   AIPlotter& operator= (const AIPlotter& oldplotter);
  2014.  public:
  2015.   /* ctors (old-style, not thread-safe) */
  2016.   AIPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2017.   AIPlotter (FILE *outfile);
  2018.   AIPlotter (istream& in, ostream& out, ostream& err);
  2019.   AIPlotter (ostream& out);
  2020.   AIPlotter ();
  2021.   /* ctors (new-style, thread-safe) */
  2022.   AIPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2023.   AIPlotter (FILE *outfile, PlotterParams ¶ms);
  2024.   AIPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2025.   AIPlotter (ostream& out, PlotterParams ¶ms);
  2026.   AIPlotter (PlotterParams ¶ms);
  2027.   /* dtor */
  2028.   virtual ~AIPlotter ();
  2029.  protected:
  2030.   /* protected methods (overriding Plotter methods) */
  2031.   bool begin_page (void);
  2032.   bool erase_page (void);
  2033.   bool end_page (void);
  2034.   void paint_point (void);
  2035.   void initialize (void);
  2036.   void terminate (void);
  2037.   void paint_path (void);
  2038.   bool paint_paths (void);
  2039.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  2040.   /* internal functions */
  2041.   void _a_set_attributes (void);
  2042.   void _a_set_fill_color (bool force_pen_color);
  2043.   void _a_set_pen_color (void);
  2044.   /* AIPlotter-specific data members */
  2045.   int ai_version;        /* AI3 or AI5? */
  2046.   double ai_pen_cyan;        /* D: pen color (in CMYK space) */
  2047.   double ai_pen_magenta;
  2048.   double ai_pen_yellow;
  2049.   double ai_pen_black;
  2050.   double ai_fill_cyan;        /* D: fill color (in CMYK space) */
  2051.   double ai_fill_magenta;
  2052.   double ai_fill_yellow;
  2053.   double ai_fill_black;
  2054.   bool ai_cyan_used;        /* D: C, M, Y, K have been used? */
  2055.   bool ai_magenta_used;
  2056.   bool ai_yellow_used;
  2057.   bool ai_black_used;
  2058.   int ai_cap_style;        /* D: cap style for lines (PS numbering)*/
  2059.   int ai_join_style;        /* D: join style for lines(PS numbering)*/
  2060.   double ai_miter_limit;    /* D: miterlimit for line joins */
  2061.   int ai_line_type;        /* D: one of L_* */
  2062.   double ai_line_width;        /* D: line width in printer's points */
  2063.   int ai_fill_rule_type;    /* D: fill rule (FILL_{ODD|NONZERO}_WINDING) */
  2064. };
  2065.  
  2066. /* The SVGPlotter class, which produces SVG output for the Web */
  2067. class SVGPlotter : public Plotter
  2068. {
  2069.  private:
  2070.   /* disallow copying and assignment */
  2071.   SVGPlotter (const SVGPlotter& oldplotter);  
  2072.   SVGPlotter& operator= (const SVGPlotter& oldplotter);
  2073.  public:
  2074.   /* ctors (old-style, not thread-safe) */
  2075.   SVGPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2076.   SVGPlotter (FILE *outfile);
  2077.   SVGPlotter (istream& in, ostream& out, ostream& err);
  2078.   SVGPlotter (ostream& out);
  2079.   SVGPlotter ();
  2080.   /* ctors (new-style, thread-safe) */
  2081.   SVGPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2082.   SVGPlotter (FILE *outfile, PlotterParams ¶ms);
  2083.   SVGPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2084.   SVGPlotter (ostream& out, PlotterParams ¶ms);
  2085.   SVGPlotter (PlotterParams ¶ms);
  2086.   /* dtor */
  2087.   virtual ~SVGPlotter ();
  2088.  protected:
  2089.   /* protected methods (overriding Plotter methods) */
  2090.   bool begin_page (void);
  2091.   bool erase_page (void);
  2092.   bool end_page (void);
  2093.   void paint_point (void);
  2094.   void initialize (void);
  2095.   void terminate (void);
  2096.   void paint_path (void);
  2097.   bool paint_paths (void);
  2098.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  2099.   /* SVGPlotter-specific internal functions */
  2100.   void _s_set_matrix (const double m_base[6], const double m_local[6]);
  2101.   /* SVGPlotter-specific data members */
  2102.   double s_matrix[6];        /* D: default transformation matrix for page */
  2103.   bool s_matrix_is_unknown;    /* D: matrix has not yet been set? */
  2104.   bool s_matrix_is_bogus;    /* D: matrix has been set, but is bogus? */
  2105.   plColor s_bgcolor;        /* D: background color (RGB) */
  2106.   bool s_bgcolor_suppressed;    /* D: background color suppressed? */
  2107. };
  2108.  
  2109. /* The PNMPlotter class, which produces PBM/PGM/PPM output; derived from
  2110.    the BitmapPlotter class */
  2111. class PNMPlotter : public BitmapPlotter
  2112. {
  2113.  private:
  2114.   /* disallow copying and assignment */
  2115.   PNMPlotter (const PNMPlotter& oldplotter);  
  2116.   PNMPlotter& operator= (const PNMPlotter& oldplotter);
  2117.  public:
  2118.   /* ctors (old-style, not thread-safe) */
  2119.   PNMPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2120.   PNMPlotter (FILE *outfile);
  2121.   PNMPlotter (istream& in, ostream& out, ostream& err);
  2122.   PNMPlotter (ostream& out);
  2123.   PNMPlotter ();
  2124.   /* ctors (new-style, thread-safe) */
  2125.   PNMPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2126.   PNMPlotter (FILE *outfile, PlotterParams ¶ms);
  2127.   PNMPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2128.   PNMPlotter (ostream& out, PlotterParams ¶ms);
  2129.   PNMPlotter (PlotterParams ¶ms);
  2130.   /* dtor */
  2131.   virtual ~PNMPlotter ();
  2132.  protected:
  2133.   /* protected methods (overriding BitmapPlotter methods) */
  2134.   void initialize (void);
  2135.   void terminate (void);
  2136.   /* internal functions that override BitmapPlotter functions (crocks) */
  2137.   int _maybe_output_image (void);
  2138.   /* other PNMPlotter-specific internal functions */
  2139.   void _n_write_pnm (void);
  2140.   void _n_write_pbm (void);
  2141.   void _n_write_pgm (void);
  2142.   void _n_write_ppm (void);
  2143.   /* PNMPlotter-specific data members */
  2144.   bool n_portable_output;    /* portable, not binary output format? */
  2145. };
  2146.  
  2147. #ifdef INCLUDE_PNG_SUPPORT
  2148. /* The PNGPlotter class, which produces PNG output; derived from the
  2149.    BitmapPlotter class */
  2150. class PNGPlotter : public BitmapPlotter
  2151. {
  2152.  private:
  2153.   /* disallow copying and assignment */
  2154.   PNGPlotter (const PNGPlotter& oldplotter);  
  2155.   PNGPlotter& operator= (const PNGPlotter& oldplotter);
  2156.  public:
  2157.   /* ctors (old-style, not thread-safe) */
  2158.   PNGPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2159.   PNGPlotter (FILE *outfile);
  2160.   PNGPlotter (istream& in, ostream& out, ostream& err);
  2161.   PNGPlotter (ostream& out);
  2162.   PNGPlotter ();
  2163.   /* ctors (new-style, thread-safe) */
  2164.   PNGPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2165.   PNGPlotter (FILE *outfile, PlotterParams ¶ms);
  2166.   PNGPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2167.   PNGPlotter (ostream& out, PlotterParams ¶ms);
  2168.   PNGPlotter (PlotterParams ¶ms);
  2169.   /* dtor */
  2170.   virtual ~PNGPlotter ();
  2171.  protected:
  2172.   /* protected methods (overriding BitmapPlotter methods) */
  2173.   void initialize (void);
  2174.   void terminate (void);
  2175.   /* internal functions that override BitmapPlotter functions (crocks) */
  2176.   int _maybe_output_image (void);
  2177.   /* PNGPlotter-specific data members */
  2178.   bool z_interlace;        /* interlaced PNG? */
  2179.   bool z_transparent;        /* transparent PNG? */
  2180.   plColor z_transparent_color;    /* if so, transparent color (24-bit RGB) */
  2181. };
  2182. #endif /* INCLUDE_PNG_SUPPORT */
  2183.  
  2184. /* The GIFPlotter class, which produces pseudo-GIF output */
  2185. class GIFPlotter : public Plotter
  2186. {
  2187.  private:
  2188.   /* disallow copying and assignment */
  2189.   GIFPlotter (const GIFPlotter& oldplotter);  
  2190.   GIFPlotter& operator= (const GIFPlotter& oldplotter);
  2191.  public:
  2192.   /* ctors (old-style, not thread-safe) */
  2193.   GIFPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2194.   GIFPlotter (FILE *outfile);
  2195.   GIFPlotter (istream& in, ostream& out, ostream& err);
  2196.   GIFPlotter (ostream& out);
  2197.   GIFPlotter ();
  2198.   /* ctors (new-style, thread-safe) */
  2199.   GIFPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2200.   GIFPlotter (FILE *outfile, PlotterParams ¶ms);
  2201.   GIFPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2202.   GIFPlotter (ostream& out, PlotterParams ¶ms);
  2203.   GIFPlotter (PlotterParams ¶ms);
  2204.   /* dtor */
  2205.   virtual ~GIFPlotter ();
  2206.  protected:
  2207.   /* protected methods (overriding Plotter methods) */
  2208.   bool begin_page (void);
  2209.   bool erase_page (void);
  2210.   bool end_page (void);
  2211.   void paint_point (void);
  2212.   void initialize (void);
  2213.   void terminate (void);
  2214.   void paint_path (void);
  2215.   bool paint_paths (void);
  2216.   /* GIFPlotter-specific internal functions */
  2217.   unsigned char _i_new_color_index (int red, int green, int blue);
  2218.   int _i_scan_pixel (void);
  2219.   void _i_delete_image (void);
  2220.   void _i_draw_elliptic_arc (plPoint p0, plPoint p1, plPoint pc);
  2221.   void _i_draw_elliptic_arc_2 (plPoint p0, plPoint p1, plPoint pc);
  2222.   void _i_draw_elliptic_arc_internal (int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange);
  2223.   void _i_new_image (void);
  2224.   void _i_set_bg_color (void);
  2225.   void _i_set_fill_color (void);
  2226.   void _i_set_pen_color (void);
  2227.   void _i_start_scan (void);
  2228.   void _i_write_gif_header (void);
  2229.   void _i_write_gif_image (void);
  2230.   void _i_write_gif_trailer (void);
  2231.   void _i_write_short_int (unsigned int i);
  2232.   /* GIFPlotter-specific data members */
  2233.   int i_xn, i_yn;        /* bitmap dimensions */
  2234.   int i_num_pixels;        /* total pixels (used by scanner) */
  2235.   bool i_animation;        /* animated (multi-image) GIF? */
  2236.   int i_iterations;        /* number of times GIF should be looped */
  2237.   int i_delay;            /* delay after image, in 1/100 sec units */
  2238.   bool i_interlace;        /* interlaced GIF? */
  2239.   bool i_transparent;        /* transparent GIF? */
  2240.   plColor i_transparent_color;    /* if so, transparent color (24-bit RGB) */
  2241.   voidptr_t i_arc_cache_data;    /* pointer to cache (used by miPolyArc_r) */
  2242.   int i_transparent_index;    /* D: transparent color index (if any) */
  2243.   voidptr_t i_painted_set;    /* D: libxmi's canvas (a (miPaintedSet *)) */
  2244.   voidptr_t i_canvas;        /* D: libxmi's canvas (a (miCanvas *)) */
  2245.   plColor i_colormap[256];    /* D: frame colormap (containing 24-bit RGBs)*/
  2246.   int i_num_color_indices;    /* D: number of color indices allocated */
  2247.   bool i_frame_nonempty;    /* D: something drawn in current frame? */
  2248.   int i_bit_depth;        /* D: bit depth (ceil(log2(num_indices))) */
  2249.   int i_pixels_scanned;        /* D: number that scanner has scanned */
  2250.   int i_pass;            /* D: scanner pass (used if interlacing) */
  2251.   plIntPoint i_hot;        /* D: scanner hot spot */
  2252.   plColor i_global_colormap[256]; /* D: colormap for first frame (stashed) */
  2253.   int i_num_global_color_indices;/* D: number of indices in global colormap */
  2254.   bool i_header_written;    /* D: GIF header written yet? */
  2255. };
  2256.  
  2257. #ifndef X_DISPLAY_MISSING
  2258. /* The XDrawablePlotter class, which draws into one or two X drawables */
  2259. class XDrawablePlotter : public Plotter
  2260. {
  2261.  private:
  2262.   /* disallow copying and assignment */
  2263.   XDrawablePlotter (const XDrawablePlotter& oldplotter);  
  2264.   XDrawablePlotter& operator= (const XDrawablePlotter& oldplotter);
  2265.  public:
  2266.   /* ctors (old-style, not thread-safe) */
  2267.   XDrawablePlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2268.   XDrawablePlotter (FILE *outfile);
  2269.   XDrawablePlotter (istream& in, ostream& out, ostream& err);
  2270.   XDrawablePlotter (ostream& out);
  2271.   XDrawablePlotter ();
  2272.   /* ctors (new-style, thread-safe) */
  2273.   XDrawablePlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2274.   XDrawablePlotter (FILE *outfile, PlotterParams ¶ms);
  2275.   XDrawablePlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2276.   XDrawablePlotter (ostream& out, PlotterParams ¶ms);
  2277.   XDrawablePlotter (PlotterParams ¶ms);
  2278.   /* dtor */
  2279.   virtual ~XDrawablePlotter ();
  2280.  protected:
  2281.   /* protected methods (overriding Plotter methods) */
  2282.   bool begin_page (void);
  2283.   bool erase_page (void);
  2284.   bool end_page (void);
  2285.   bool flush_output (void);
  2286.   bool path_is_flushable (void);
  2287.   void push_state (void);
  2288.   void pop_state (void);
  2289.   void paint_point (void);
  2290.   void initialize (void);
  2291.   void terminate (void);
  2292.   void paint_path (void);
  2293.   bool paint_paths (void);
  2294.   void maybe_prepaint_segments (int prev_num_segments);
  2295.   double paint_text_string (const unsigned char *s, int h_just, int v_just);
  2296.   double get_text_width (const unsigned char *s);
  2297.   bool retrieve_font (void);
  2298.   /* internal functions that are overridden in the XPlotter class (crocks) */
  2299.   virtual void _maybe_get_new_colormap (void);
  2300.   virtual void _maybe_handle_x_events (void);
  2301.   /* other XDrawablePlotter-specific internal functions */
  2302.   bool _x_retrieve_color (XColor *rgb_ptr);
  2303.   bool _x_select_font (const char *name, bool is_zero[4], const unsigned char *s);
  2304.   bool _x_select_font_carefully (const char *name, bool is_zero[4], const unsigned char *s);
  2305.   bool _x_select_xlfd_font_carefully (const char *x_name, const char *x_name_alt, double user_size, double rotation);
  2306.   void _x_add_gcs_to_first_drawing_state (void);
  2307.   void _x_delete_gcs_from_first_drawing_state (void);
  2308.   void _x_draw_elliptic_arc (plPoint p0, plPoint p1, plPoint pc);
  2309.   void _x_draw_elliptic_arc_2 (plPoint p0, plPoint p1, plPoint pc);
  2310.   void _x_draw_elliptic_arc_internal (int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange);
  2311.   void _x_set_attributes (int x_gc_type);
  2312.   void _x_set_bg_color (void);
  2313.   void _x_set_fill_color (void);
  2314.   void _x_set_font_dimensions (bool is_zero[4]);
  2315.   void _x_set_pen_color (void);
  2316.   /* XDrawablePlotter-specific data members */
  2317.   Display *x_dpy;        /* X display */
  2318.   Visual *x_visual;        /* X visual */
  2319.   Drawable x_drawable1;        /* an X drawable (e.g. a pixmap) */
  2320.   Drawable x_drawable2;        /* an X drawable (e.g. a window) */
  2321.   Drawable x_drawable3;        /* graphics buffer, if double buffering */
  2322.   int x_double_buffering;    /* double buffering type (if any) */
  2323.   long int x_max_polyline_len;    /* limit on polyline len (X display-specific)*/
  2324.   plFontRecord *x_fontlist;    /* D: head of list of retrieved X fonts */
  2325.   plColorRecord *x_colorlist;    /* D: head of list of retrieved X color cells*/
  2326.   Colormap x_cmap;        /* D: colormap (dynamic only for XPlotters) */
  2327.   int x_cmap_type;        /* D: colormap type (orig./copied/bad) */
  2328.   bool x_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  2329.   bool x_bg_color_warning_issued; /* D: issued warning on bg color */
  2330.   int x_paint_pixel_count;    /* D: times point() is invoked to set a pixel*/
  2331. };
  2332.  
  2333. /* The XPlotter class, which pops up a window and draws into it */
  2334. class XPlotter : public XDrawablePlotter
  2335. {
  2336.  private:
  2337.   /* disallow copying and assignment */
  2338.   XPlotter (const XPlotter& oldplotter);  
  2339.   XPlotter& operator= (const XPlotter& oldplotter);
  2340.  public:
  2341.   /* ctors (old-style, not thread-safe) */
  2342.   XPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2343.   XPlotter (FILE *outfile);
  2344.   XPlotter (istream& in, ostream& out, ostream& err);
  2345.   XPlotter (ostream& out);
  2346.   XPlotter ();
  2347.   /* ctors (new-style, thread-safe) */
  2348.   XPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶ms);
  2349.   XPlotter (FILE *outfile, PlotterParams ¶ms);
  2350.   XPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶ms);
  2351.   XPlotter (ostream& out, PlotterParams ¶ms);
  2352.   XPlotter (PlotterParams ¶ms);
  2353.   /* dtor */
  2354.   virtual ~XPlotter ();
  2355.  protected:
  2356.   /* protected methods (overriding XDrawablePlotter methods) */
  2357.   bool begin_page (void);
  2358.   bool erase_page (void);
  2359.   bool end_page (void);
  2360.   void initialize (void);
  2361.   void terminate (void);
  2362.   /* internal functions that override XDrawablePlotter functions (crocks) */
  2363.   void _maybe_get_new_colormap (void);
  2364.   void _maybe_handle_x_events (void);
  2365.   /* other XPlotter-specific internal functions */
  2366.   void _y_set_data_for_quitting (void);
  2367.   /* XPlotter-specific data members (non-static) */
  2368.   XtAppContext y_app_con;    /* application context */
  2369.   Widget y_toplevel;        /* toplevel widget */
  2370.   Widget y_canvas;        /* Label widget */
  2371.   Drawable y_drawable4;        /* used for server-side double buffering */
  2372.   bool y_auto_flush;        /* do an XFlush() after each drawing op? */
  2373.   bool y_vanish_on_delete;    /* window(s) disappear on Plotter deletion? */
  2374.   pid_t *y_pids;        /* D: list of pids of forked-off processes */
  2375.   int y_num_pids;        /* D: number of pids in list */
  2376.   int y_event_handler_count;    /* D: times that event handler is invoked */
  2377.   /* XPlotter-specific data members (static) */
  2378.   static XPlotter **_xplotters;    /* D: sparse array of XPlotter instances */
  2379.   static int _xplotters_len;    /* D: length of sparse array */
  2380. };
  2381. #endif /* not X_DISPLAY_MISSING */
  2382. #endif /* not NOT_LIBPLOTTER */
  2383.  
  2384.  
  2385. /***********************************************************************/
  2386.  
  2387. /* Useful definitions, included in both plot.h and plotter.h. */
  2388.  
  2389. #ifndef _PL_LIBPLOT_USEFUL_DEFS
  2390. #define _PL_LIBPLOT_USEFUL_DEFS 1
  2391.  
  2392. /* Symbol types for the marker() function, extending over the range 0..31.
  2393.    (1 through 5 are the same as in the GKS [Graphical Kernel System].)
  2394.  
  2395.    These are now defined as enums rather than ints.  Cast them to ints if
  2396.    necessary. */
  2397. enum 
  2398. { M_NONE, M_DOT, M_PLUS, M_ASTERISK, M_CIRCLE, M_CROSS, 
  2399.   M_SQUARE, M_TRIANGLE, M_DIAMOND, M_STAR, M_INVERTED_TRIANGLE, 
  2400.   M_STARBURST, M_FANCY_PLUS, M_FANCY_CROSS, M_FANCY_SQUARE, 
  2401.   M_FANCY_DIAMOND, M_FILLED_CIRCLE, M_FILLED_SQUARE, M_FILLED_TRIANGLE, 
  2402.   M_FILLED_DIAMOND, M_FILLED_INVERTED_TRIANGLE, M_FILLED_FANCY_SQUARE,
  2403.   M_FILLED_FANCY_DIAMOND, M_HALF_FILLED_CIRCLE, M_HALF_FILLED_SQUARE,
  2404.   M_HALF_FILLED_TRIANGLE, M_HALF_FILLED_DIAMOND,
  2405.   M_HALF_FILLED_INVERTED_TRIANGLE, M_HALF_FILLED_FANCY_SQUARE,
  2406.   M_HALF_FILLED_FANCY_DIAMOND, M_OCTAGON, M_FILLED_OCTAGON 
  2407. };
  2408.  
  2409. /* ONE-BYTE OPERATION CODES FOR GNU METAFILE FORMAT. These are now defined
  2410.    as enums rather than ints.  Cast them to ints if necessary.
  2411.  
  2412.    There are 85 currently recognized op codes.  The first 10 date back to
  2413.    Unix plot(5) format. */
  2414.  
  2415. enum
  2416. {  
  2417. /* 10 op codes for primitive graphics operations, as in Unix plot(5) format. */
  2418.   O_ARC        =    'a',  
  2419.   O_CIRCLE    =    'c',  
  2420.   O_CONT    =    'n',
  2421.   O_ERASE    =    'e',
  2422.   O_LABEL    =    't',
  2423.   O_LINEMOD    =    'f',
  2424.   O_LINE    =    'l',
  2425.   O_MOVE    =    'm',
  2426.   O_POINT    =    'p',
  2427.   O_SPACE    =    's',
  2428.   
  2429. /* 42 op codes that are GNU extensions */
  2430.   O_ALABEL    =    'T',
  2431.   O_ARCREL    =    'A',
  2432.   O_BEZIER2    =       'q',
  2433.   O_BEZIER2REL    =       'r',
  2434.   O_BEZIER3    =       'y',
  2435.   O_BEZIER3REL    =       'z',
  2436.   O_BGCOLOR    =    '~',
  2437.   O_BOX        =    'B',    /* not an op code in Unix plot(5) */
  2438.   O_BOXREL    =    'H',
  2439.   O_CAPMOD    =    'K',
  2440.   O_CIRCLEREL    =    'G',
  2441.   O_CLOSEPATH    =    'k',
  2442.   O_CLOSEPL    =    'x',    /* not an op code in Unix plot(5) */
  2443.   O_COMMENT    =    '#',
  2444.   O_CONTREL    =    'N',
  2445.   O_ELLARC    =    '?',
  2446.   O_ELLARCREL    =    '/',
  2447.   O_ELLIPSE    =    '+',
  2448.   O_ELLIPSEREL    =    '=',
  2449.   O_ENDPATH    =    'E',
  2450.   O_ENDSUBPATH    =    ']',
  2451.   O_FILLTYPE    =    'L',
  2452.   O_FILLCOLOR    =    'D',
  2453.   O_FILLMOD    =    'g',
  2454.   O_FONTNAME    =    'F',
  2455.   O_FONTSIZE    =    'S',
  2456.   O_JOINMOD    =    'J',
  2457.   O_LINEDASH    =     'd',
  2458.   O_LINEREL    =    'I',
  2459.   O_LINEWIDTH    =    'W',
  2460.   O_MARKER    =    'Y',
  2461.   O_MARKERREL    =    'Z',
  2462.   O_MOVEREL    =    'M',
  2463.   O_OPENPL    =    'o',    /* not an op code in Unix plot(5) */
  2464.   O_ORIENTATION    =    'b',
  2465.   O_PENCOLOR    =    '-',
  2466.   O_PENTYPE    =    'h',
  2467.   O_POINTREL    =    'P',
  2468.   O_RESTORESTATE=    'O',
  2469.   O_SAVESTATE    =    'U',
  2470.   O_SPACE2    =    ':',
  2471.   O_TEXTANGLE    =    'R',
  2472.  
  2473. /* 30 floating point counterparts to many of the above.  They are not even
  2474.    slightly mnemonic. */
  2475.   O_FARC    =    '1',
  2476.   O_FARCREL    =    '2',
  2477.   O_FBEZIER2    =       '`',
  2478.   O_FBEZIER2REL    =       '\'',
  2479.   O_FBEZIER3    =       ',',
  2480.   O_FBEZIER3REL    =       '.',
  2481.   O_FBOX    =    '3',
  2482.   O_FBOXREL    =    '4',
  2483.   O_FCIRCLE    =    '5',
  2484.   O_FCIRCLEREL    =    '6',
  2485.   O_FCONT    =    ')',
  2486.   O_FCONTREL    =    '_',
  2487.   O_FELLARC    =    '}',
  2488.   O_FELLARCREL    =    '|',
  2489.   O_FELLIPSE    =    '{',
  2490.   O_FELLIPSEREL    =    '[',
  2491.   O_FFONTSIZE    =    '7',
  2492.   O_FLINE    =    '8',
  2493.   O_FLINEDASH    =     'w',
  2494.   O_FLINEREL    =    '9',
  2495.   O_FLINEWIDTH    =    '0',
  2496.   O_FMARKER    =    '!',
  2497.   O_FMARKERREL    =    '@',
  2498.   O_FMOVE    =    '$',
  2499.   O_FMOVEREL    =    '%',
  2500.   O_FPOINT    =    '^',
  2501.   O_FPOINTREL    =    '&',
  2502.   O_FSPACE    =    '*',
  2503.   O_FSPACE2    =    ';',
  2504.   O_FTEXTANGLE    =    '(',
  2505.  
  2506. /* 3 op codes for floating point operations with no integer counterpart */
  2507.   O_FCONCAT        =    '\\',
  2508.   O_FMITERLIMIT        =    'i',
  2509.   O_FSETMATRIX        =    'j'
  2510. };
  2511.  
  2512. #endif /* not _PL_LIBPLOT_USEFUL_DEFS */
  2513.  
  2514. /***********************************************************************/
  2515.  
  2516. #endif /* not _PLOTTER_H_ */
  2517.